1

タブアクティビティがあり、1 つのタブ内にアクティビティグループがあります。最初にアクティビティ A が表示され、そこから startactivityforresult を使用してアクティビティ B を呼び出します。これを達成する方法は?

私の活動Aでは、私はこれをやっています...

        Intent i = new Intent(Entry.this, Child.class);

        // Create the view using FirstGroup's LocalActivityManager  
        View view = GroupActivity.group.getLocalActivityManager()  
        .startActivity("child", i  
        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))  
        .getDecorView();  

        // Again, replace the view  
        GroupActivity.group.replaceView(view);

これはアクティビティ B に移動しますが、そこからアクティビティ A に戻る方法はありません。

4

1 に答える 1

0

startActivity を次のように変更します。

.startActivityForResult(i, .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));

次に、このメソッドを ActivityA に追加します。

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // See which child activity is calling us back.
        switch (resultCode) {
           case RESULT_OK:
           {
               //processing code goes here
           }
           default:
                break;
        }
} 

その後、アクティビティ B で finish() が呼び出されたら、「OnActivityResult」メソッドをヒットする必要があります。次を呼び出して、インテントをメイン アクティビティに送り返すこともできます。

setResult(Activity.Result_OK, intent);

アクティビティ B で。

于 2011-06-21T11:34:07.873 に答える