※不是App2sd的问题。
(首先,您可以在 android market 中试用此应用程序)
https://market.android.com/details?id=com.beadgrip.premierframe
这是一个 PictureFrame 小部件。
一个 Widget 布局中有两个 ImageView(2x2 大小)
<强>1。在主屏幕上添加一个小部件 -> 当然会出现!
<强>2。重启->消失(有时会出现...很奇怪的问题..)
<强>3。但是如果我旋转屏幕 -> 出现
此问题发生在 LG、SamSung、CM7 Roms(以及各种“Home Launcher App”)以下的设备上
但是,HTC Sense 和 MIUI 没问题
更奇怪的是..
如果我删除 WidgetLayout XML 中的一个 ImageView -> 没问题!!!
(或者不是 setImageBitmap,其中 provider.java 源是框架或图片位图之一)
这是问题的内核来源。
provider.java源码
// Update Widget Method
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
PFramePhotoDatabase helper = new PFramePhotoDatabase(context);
for (int appWidgetId : appWidgetIds) {
int[] specificAppWidget = new int[] { appWidgetId };
RemoteViews views = buildUpdate(context, appWidgetId, helper);
appWidgetManager.updateAppWidget(specificAppWidget, views);
}
helper.close();
}
static RemoteViews buildUpdate(Context context, int appWidgetId, PFramePhotoDatabase helper) {
RemoteViews views = null;
// Getting a frame, picture from SQLite
Bitmap bitmap_Pic = helper.getPhotoPicture(appWidgetId);
Bitmap bitmap_Frm = helper.getPhotoFrame(appWidgetId);
views = new RemoteViews(context.getPackageName(), R.layout.layout_widget22);
// If I delete one 'if' it's not problem!, it's perfect!
// So I devided buildUpdate Method as two kinds, But It's same problem :<
if (bitmap_Pic != null) {
views.setImageViewBitmap(R.id.wiv_Picture22, bitmap_Pic); // Picture set a ImageView
}
if (bitmap_Frm != null) {
views.setImageViewBitmap(R.id.wiv_Frame22, bitmap_Frm); // Frame set a ImageView
}
return views;
}
最佳答案
您只需在 onReceive ()
方法中调用 super.onReceive ()
即可防止小部件管理器生命周期中断。
关于Android 小部件,重启后它没有显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7483871/