Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8444411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:23:38+00:00 2026-06-10T09:23:38+00:00

i am developing android widget and i displayed some data on that widget from

  • 0

i am developing android widget and i displayed some data on that widget from web service and its working fine.Hear is the code for that.

CODE

public class WatchWidget extends AppWidgetProvider{


    private static final String TAG = "WatchWidget";

    @Override
    public void onUpdate( Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds ){
        Log.i(TAG, "* onUpdate");


        EBWeaterData ebwd=new EBWeaterData();

        EBWeatreUtils.getWeatherFeeds(context, ebwd, "my url to get data");

        RemoteViews views = new RemoteViews(context.getPackageName(),R.layout.main);
        RemoteViews newView = new RemoteViews(context.getPackageName(), R.layout.test);

        //get data 
        String day=ebwd.getDay_1()+ebwd.getDay_suffix_1()+" "+ebwd.getDay_name_1();
        String minmaxtemp="Max Temp "+ebwd.getDay_max_temp_1()+"°C "+"Min Temp "+ebwd.getDay_min_temp_1()+"°C";

        //set dat to views
        newView.setTextViewText(R.id.textView_day_name, day);
        newView.setTextViewText(R.id.textView_minmaxtemp, minmaxtemp);  
        newView.setImageViewResource(R.id.ImageView_icon, R.drawable.sunny);

        views.addView(R.id.view_container, newView);      
        ComponentName thisWidget = new ComponentName(context,WatchWidget.class);
        AppWidgetManager manager = AppWidgetManager.getInstance(context);
        manager.updateAppWidget(thisWidget, views);

    }

}

i have a button on that widget now i want to update the widget view with different values when user clicks on the button.I know I have to do with it pendingIntent like following.

      Intent intent = new Intent(context, activitytogetNewdata.class);
      PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
      views.setOnClickPendingIntent(R.id.imageView1, pendingIntent);

But it will start another activity i dont want to go to anther activity.I just need to do is to update the same widget view with new values after button click.Any Idea??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:23:39+00:00Added an answer on June 10, 2026 at 9:23 am

    I have found the problem of my code.when i going to update my view using pendingintent it will dynamically add view on each and every button click because i have used 2 layout hear so i solved the problem as follows.(i use one layout instead of using two)

    CODE

    public class WatchWidget extends AppWidgetProvider{
    
    
        private static final String TAG = "WatchWidget";
    
        @Override
        public void onUpdate( Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds ){
            Log.i(TAG, "* onUpdate");
    
    
            EBWeaterData ebwd=new EBWeaterData();
    
            EBWeatreUtils.getWeatherFeeds(context, ebwd, "my url to get data");
    
    
            RemoteViews newView = new RemoteViews(context.getPackageName(), R.layout.test);
    
            //get data 
            String day=ebwd.getDay_1()+ebwd.getDay_suffix_1()+" "+ebwd.getDay_name_1();
            String minmaxtemp="Max Temp "+ebwd.getDay_max_temp_1()+"°C "+"Min Temp "+ebwd.getDay_min_temp_1()+"°C";
    
            //set dat to views
            newView.setTextViewText(R.id.textView_day_name, day);
            newView.setTextViewText(R.id.textView_minmaxtemp, minmaxtemp);  
            newView.setImageViewResource(R.id.ImageView_icon, R.drawable.sunny);
    
    
            ComponentName thisWidget = new ComponentName(context,WatchWidget.class);
            AppWidgetManager manager = AppWidgetManager.getInstance(context);
            manager.updateAppWidget(thisWidget, newView);
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an android app (only Widget) which displays some images from a
I am developing an Android widget. I have an initial layout from the XML
Im developing an android App I want to read the data in from Excel
I'm developing an Android 3.1 tablet application. I've found a really nice widget ViewPager
I have difficulties developing 4x1 widget for Android. This is the appprovider <?xml version=1.0
I'm developing android application for CAR usage and I need that in phone or
I am developing android application in which i have to open option menu from
I am developing android web application for a blog like website. For this I
I am new to android widget and currently i am developing widget where i
I used to have some experience with developing for android but I started up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.