0

2 つのアクティビティ (A と B など) と appWidget を持つ小さなアプリケーションがあります。ウィジェットをクリックするとアクティビティが開始され、いくつかのことをしながらウィジェットがアニメーション化されます。私はこのようにしています。

Intent intent = new Intent(context, DialogActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main);
RemoteViews.setOnClickPendingIntent(R.id.imageButton1, pendingIntent);

のアクティビティは次のことをonCreate行います。

    Paint p = new Paint();
    p.setStyle(Paint.Style.FILL);
    p.setColor(Color.TRANSPARENT);

    logger.debug("inizializzo movie"); //$NON-NLS-1$
    Movie movie;
    InputStream is = null;
    long moviestart = 0;
    is = this.getResources().openRawResource(R.drawable.gifanimata);
    movie = Movie.decodeStream(is);

    taskIsrunning = true;

    //this is an AsyncTask that at the end of the work sets taskIsrunning = false
    new InitTask().execute(this);
    while (taskIsrunning) {

    Bitmap bitmap = Bitmap.createBitmap(100, 100, Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    canvas.drawRect(0, 0, 100, 100, p);

    long now = android.os.SystemClock.uptimeMillis();

    if (moviestart == 0) { // first time
    moviestart = now;

    }
    int relTime = (int) ((now - moviestart) % movie.duration());
    movie.setTime(relTime);

    movie.draw(canvas, 0, 0);
    updateViews.setImageViewBitmap(R.id.imageButton1, bitmap);
    widgetManager.updateAppWidget(theWidget, updateViews);
    try {
    Thread.sleep(500);
    } catch (Exception e) {
    throw e;
    }
    }

最後に、このアクティビティから (魔女は完全に透明です) ダイアログを表示します。これは私が望むように機能しますが、ここに問題があります:

アクティビティを起動するときに、以前にアプリケーションの最初のアクティビティ (アクティビティ A) を開き、[戻る] ボタンで閉じるのではなく、ホーム ボタンで閉じた (アクティビティはスタックに残っている) 場合、ダイアログを表示する瞬間ウィジェットによって起動されたアクティビティから、ダイアログが表示されますが、アクティビティ A も同様です。

マニフェスト android:noHistory="true" の設定を試してみましたが、問題は解決しましたが、アクティビティ A からアクティビティ B を起動すると、戻るボタンでアクティビティ A が表示されません。

4

0 に答える 0