アクティビティの 1 つが stack.back ボタンで正しく機能しない理由を突き止めようとしています。
ユーザーが Main アクティビティで画像ボタンを押すと、Activity Brain が起動します。これは正常に機能し、戻るボタンは Brain から期待どおりに動作します (つまり、期待どおりにメイン アクティビティに戻ります)。
脳内で、ユーザーが押した画像ボタンに基づいて PDF を起動したいのですが、以下のコードを使用して URI を介してこれを実行しています。PDF は正常に読み込まれますが、アクロバット内で戻ると、アプリは脳ではなくメイン アクティビティに戻ります。これは私が望む(または期待する)動作ではありません。私はアプリ開発者ガイドを読み、Intent Flag_activity ですべてのオプションを試しましたが (私はそう思います)、戻るボタンの動作を修正できませんでした。別のPDFにリンクしようとしましたが(アクロバットでランダムなものだった場合)、アプリは同じように動作し、常にメインに戻り、必要な頭脳には戻りません。
私は Imagebuttons を使用して、ユーザーが pdf を選択できるようにしています。以下のコードは、pdf を表示するための URI / インテントを呼び出しています。私が試した Intent.Flags のうち 2 つを残しましたが、増幅のために運がありませんでした。Intent.Flag_Activity_Clear_Top が機能することを期待していましたが、何かを見逃したに違いありません。
脳の活動は、次の onClick コードを使用して main から呼び出されます
 if (v==bbrain) {
                    Intent startbrain = new Intent(Main.this, Brain.class); //this is the Brain chooser
                    startActivity(startbrain);
                overridePendingTransition(R.anim.pull_from_left_enter, R.anim.pull_out_to_left_exit);
                    }
すると、脳活動 java は次のようになります。
public void onClick(View v) {
            if (v==bhome); {
            Intent starthome = new Intent(Brain.this, Main.class); //this is main screen
            startActivity(starthome);
            overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
            }
            if (v==babouttest){
                Intent start1gp = new Intent(Brain.this, AboutScreen.class); //this is 1gp lesson
                startActivity(start1gp);
                overridePendingTransition(R.anim.pull_from_left_enter, R.anim.pull_out_to_left_exit);
            }
            if (v==imagepetro) {
                File file = new File("/sdcard/documents/1.pdf");
                  if (file.exists()) {
                        Uri path = Uri.fromFile(file);
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setDataAndType(path, "application/pdf");
                        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        try {
                            startActivity(intent);
                            overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
                        } 
                        catch (ActivityNotFoundException e) {
                        }
                  }
            }   //end of load
 if (v==imagesteam) {
                File file = new File("/sdcard/documents/2.pdf");
                  if (file.exists()) {
                        Uri path = Uri.fromFile(file);
                        Intent intent = new Intent(Intent.ACTION_VIEW);
                        intent.setDataAndType(path, "application/pdf");
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        try {
                            startActivity(intent);
                            overridePendingTransition(R.anim.zoom_enter, R.anim.zoom_exit);
                        } 
                        catch (ActivityNotFoundException e) {
                        }
                  }
            }   //end of load
   }
  //menu inflator bits
          @Override
            public boolean onCreateOptionsMenu(Menu menu) {
                getMenuInflater().inflate(R.menu.activity_brain, menu);
                return true;
            }  
            @Override
            public boolean onOptionsItemSelected(MenuItem item) {
                switch (item.getItemId()) {
                    case android.R.id.home:
                        NavUtils.navigateUpFromSameTask(this);
                        return true;
                }
                return super.onOptionsItemSelected(item);
            }
}
このアプリを書いているときに、他の場所で何かを見逃していないかどうかわかりませんか? 以下は、マニフェストからの脳と主な活動セクションです。違いがある場合
   <activity
        android:name=".Main"
        android:label="@string/title_activity_main"
        android:screenOrientation="landscape" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <!-- <category android:name="android.intent.category.LAUNCHER" /> -->
        </intent-filter>
    </activity>
 <activity
        android:name=".Brain"
        android:label="@string/title_activity_brain"
        android:screenOrientation="landscape" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.trainer.Main" />
    </activity>
このコードが機能しない理由がまったくわかりません。他のアクティビティで他の場所から PDF を起動していますが、URI の方法はうまく機能しています。
十分な詳細を提供できれば幸いです。そうでない場合は、何を含めるべきか教えてください。助けてくれてありがとう、アンディ