November 30th, 2012, 01:58 AM
|
#1 (permalink)
|
|
New Member
Thread Author (OP)
Join Date: Nov 2012
Posts: 1
Device(s):
Carrier: Not Provided
Thanks: 0
Thanked 0 Times in 0 Posts
|
Image in android widget
I'm trying to make a widget which changes displayed image from sdcard in specific timeer. My onUpdate function looks like:
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
ComponentName thisWidget = new ComponentName(context, PhotoWidgetProvider.class);
boolean mExternalStorageWriteable = false;
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state))
mExternalStorageWriteable = true;
if(mExternalStorageWriteable) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 2;
//of course it's a sample filename
String fileName = Environment.getExternalStorageDirectory().getPath() + "/DCIM/100MEDIA/IMAG0159.jpg";
Bitmap bitmap = BitmapFactory.decodeFile(fileName, options);
remoteViews.setImageViewBitmap(R.id.widget_imageview, bitmap);
appWidgetManager.updateAppWidget(thisWidget, remoteViews);
}
}But I can not see any photo on my widget. File of course exists.
|
|
|
Last edited by lesio; November 30th, 2012 at 02:06 AM.
|
|