Android download image as widget

All your problems with Audio, Video and Images.

Android download image as widget

Postby petnagy » Mon Oct 04, 2010 7:19 pm

Hi Everybody,

I am new here, but I have a problem, I have written a program which periodically load an image from the net (bitmap, and from URL) but after a couple success download it will send some FAILED BIND TRANSACTION in the logcat.
Could someone help me, what could be wrong ?

Code: Select all
public class WidgetImage extends AppWidgetProvider{
    Timer timer = new Timer();
    public void onDeleted(Context context, int[] appWidgetIds) {
    public void onUpdate(Context context, AppWidgetManager appWidgetManager,
            int[] appWidgetIds) {
        timer.scheduleAtFixedRate(new MyTime(context, appWidgetManager), 10,10000);
    public void onReceive(Context context, Intent intent) {
        // v1.5 fix that doesn't call onDelete Action
        final String action = intent.getAction();
        if (AppWidgetManager.ACTION_APPWIDGET_DELETED.equals(action)) {
            final int appWidgetId = intent.getExtras().getInt(AppWidgetManager.EXTRA_APPWIDGET_ID,
            if (appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID) {
                this.onDeleted(context, new int[] { appWidgetId });
        } else {
            super.onReceive(context, intent);

    private class MyTime extends TimerTask {
        RemoteViews remoteViews;
        AppWidgetManager appWidgetManager;
        ComponentName thisWidget;
        DateFormat format = SimpleDateFormat.getTimeInstance(SimpleDateFormat.MEDIUM, Locale.getDefault());

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

        public void run() {
            remoteViews.setTextViewText(, "Time = "+ format.format(new Date()));
            try {
                /* Open a new URL and get the InputStream to load data from it. */
                URL aURL = new URL("");
                URLConnection conn = aURL.openConnection();
                InputStream is = conn.getInputStream();
                /* Buffered is always good for a performance plus. */
                BufferedInputStream bis = new BufferedInputStream(is);
                /* Decode url-data to a bitmap. */
                Bitmap bm = BitmapFactory.decodeStream(bis);
                /* Apply the Bitmap to the ImageView that will be returned. */
                remoteViews.setImageViewBitmap(, bm);
            } catch (IOException e) {
                Log.e("DEBUGTAG", "Remtoe Image Exception", e);
            appWidgetManager.updateAppWidget(thisWidget, remoteViews);
Posts: 2
Joined: Sun Oct 03, 2010 9:08 pm


Re: Android download image as widget

Postby kuwamebrown » Fri Dec 24, 2010 7:38 am

Can someone help me out!, I've been strugling for a days trying to figure out how to make a button which able the user to download a file such as mp3 or text, I tried to search in everywhere but failed to succeed, some of the code that I used just let me open a new browser, I want the user to open to be able to download the file inside of my own app. PLease if you have an easy way to do it would you be kind to show me! I would I appreciate your kindness thanks.
Junior Developer
Junior Developer
Posts: 11
Joined: Fri Dec 24, 2010 7:28 am


Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 18 guests