KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to set image in image view in widget layout in onUpdate, but image is not updating @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { Log.i(TAG, "onUpdate called"); for (int appWidgetId : appWidgetIds) { Bitmap bitmap=ImageUtils.getBitmap(context, appWidgetId); RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.widget); remoteView.setImageViewBitmap(R.id.imgView,bitmap); appWidgetManager.updateAppWidget(appWidgetId, remoteView); } } xml layout for widget <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:id="@+id/imgView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/ic_launcher" /> </LinearLayout> Manifest file <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.demo.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".WidgetConfig" android:label="@string/app_name" > <intent-filter> <action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
Tags (comma-separated)
Save Edits
Cancel