android - Image in Widget -
i trying set image in image view in widget layout in onupdate, image not updating
@override public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) { log.i(tag, "onupdate called"); (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 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" /> </intent-filter> </activity> <receiver android:name="basicwidgetprovider"> <intent-filter> <action android:name="android.appwidget.action.appwidget_update" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info" /> </receiver> <receiver android:name="basicwidgetprovider"> <intent-filter> <action android:name="android.appwidget.action.appwidget_update" /> <data android:scheme="widget" /> </intent-filter> <meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info" /> </receiver> </application>
widget_info.xml
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" android:minwidth="25dp" android:minheight="25dp" android:initiallayout="@layout/widget" android:configure="com.demo.widgetconfig" android:widgetcategory="home_screen|keyguard" android:previewimage="@layout/widget" android:resizemode="horizontal|vertical" android:initialkeyguardlayout="@layout/widget" android:minresizeheight="5dp" android:minresizewidth="5dp"> </appwidget-provider>
but when try load widget, toast "app isnt installed", not showing such toast comes??
why image not setting, how fix it??
make sure have correct package name set in "android:configure" field in appwidget-provider xml , , have correct intetn-filter set in manifest file.
Comments
Post a Comment