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 8401683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:52:15+00:00 2026-06-09T21:52:15+00:00

Im trying to load an image from my webserver and display it as an

  • 0

Im trying to load an image from my webserver and display it as an Android widget. Im trying to have the widget update every 60 minutes as well since the image can change. The image should be clickable as well. I had the clickable part working perfectly with a button, but when I change it to an ImageView instead in my layout, the click portion ceases to work. And I cannot get the image to load at all. Here is my code

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Toast.makeText(context, "onUpdate", Toast.LENGTH_SHORT).show();

RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
Intent i = new Intent(context, LoadPage.class);
i.setAction(ACTION_WIDGET_LOAD);

PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
remoteViews.setOnClickPendingIntent(R.id.button, pi);

appWidgetManager.updateAppWidget(appWidgetIds, remoteViews);

Timer timer = new Timer();
timer.scheduleAtFixedRate(new MyButton(context, appWidgetManager), 1, 5000);
}

private class MyButton extends TimerTask {
RemoteViews remoteViews;
AppWidgetManager appWidgetManager;
ComponentName thisWidget;

public MyButton(Context context, AppWidgetManager appWidgetManager) {
  this.appWidgetManager = appWidgetManager;
  remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
  thisWidget = new ComponentName(context, ButtonWidget.class);
}

@Override
public void run() {
  Bitmap buttonimg = null;
  try {
    String name = "http://badams.ca/otwstats/get_stats.php?user=badams";
    URL url_value = new URL(name);
    buttonimg = BitmapFactory.decodeStream(url_value.openConnection().getInputStream());
  } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }

  i++;
  remoteViews.setBitmap(R.id.button, "setButton", buttonimg);
  appWidgetManager.updateAppWidget(thisWidget, remoteViews);
}
  • 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-09T21:52:16+00:00Added an answer on June 9, 2026 at 9:52 pm

    I managed to fix this. I was setting the image incorrectly.

    Replaced:

    remoteViews.setBitmap(R.id.button, "setButton", buttonimg);
    

    with:

    remoteViews.setImageViewBitmap(R.id.button, buttonimg);
    

    and that worked flawlessly!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use threading to load an image from a url. I have
I'm trying to load an image from the web. The code I have so
I'm trying to load an image from an external site over which I have
I'm trying to load an image from a URL in Silverlight and have followed
I'm trying to dynamically load an image from a javascript file. How I can
I'm trying to load image from a plist to a custom cell. It all
Im loading an image from a SQL CE db and then trying to load
I'm trying to write code that will load an image from a resource, and
I am trying to load an image in memory but might have memory issues
I'm trying to load an image into an UIImageView from the internet. This is

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.