私の最初のAndroidウィジェットを入手して、Visual Studio ProからEclipseに移行するのはスムーズなことではありません!とにかく私は上記のエラーに遭遇し、それは私に解決するのにいくつかの問題を与えます。重複する可能性のあるものをすべて検索しましたが、アプリがIPCサイズ(つまり大きな画像)に達すると、このエラーが発生するようです。
私の小さなウィジェットは、Webからいくつかの情報と1つの画像をダウンロードするためのintentserviceを起動します。pngの元の画像サイズは約100kです。ただし、ウィジェットを更新する前に、約17kにダウンスケールします。(メモリトラッカーのサイズが16400bytes []であるかどうかを確認)。それでも更新は失敗します。画像を削除すると、更新は成功します。
これは、実行されるwidgetproviderのリスナーです。
public void onHttpLoaded(Bitmap image, String titlestring, String subtitlestring)
{
Context context = getApplicationContext();
if (image == null) //no data?
{
Toast.makeText(context, context.getResources().getString(R.string.null_data_toast), Toast.LENGTH_LONG);
return;// exit!
}
try
{
RemoteViews widgetView = new RemoteViews(this.getPackageName(), R.layout.main);
widgetView.setTextViewText(R.id.title, titlestring);
//all other comment out
//The problem!
widgetView.setImageViewBitmap(R.id.main_icon, image);
//Get global appwidgetmanager
AppWidgetManager manager = AppWidgetManager.getInstance(this);
//update widget
manager.updateAppWidget(Constants.THIS_APPWIDGET, widgetView);
}
catch (Exception e)
{
Log.d("onHttpLoaded", e.toString());
}
}
上記のコードが呼び出される私のサービスからのonHandleIntent:
protected void onHandleIntent(Intent intent)
{
resources = getApplicationContext().getResources();
int iAppWidgetId;
try
{
iAppWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
catch (Exception e)
{
Log.d("Service", "WidgetID not found");
}
//comment out stuff...
//launch new httpTask
httpTask myhttpTask = new httpTask(tittlestring, subtitlestring, (myHttpListener) MyUpdateService.this, MyUpdateService.this);
//limit size of bitmap
myhttpTask.setSampleSize(Constants.BITMAP_SAMPLE_SIZE); //size = 4
myhttpTask.execute();
}
すべてのテストはエミュレーターで行われます。重要な詳細の1つは、logcatで「!!!失敗したバインダートランザクション!!!」という20〜30の失敗メッセージが表示されることです。私がこれをどのように台無しにしたかについてのアイデアはありますか?thnks!