Android onActivityResult NEVER called

前端 未结 7 707
执笔经年
执笔经年 2020-12-04 03:03

my onActivityResult method is never called. am using android 2.2

I am using a Tabhost, where TabHosts contain TabGroups which contain individual Activities.

7条回答
  •  余生分开走
    2020-12-04 03:40

    The solution is to call a transparent activity over top of the main activity. This transparent activity is in front of the tabhost and will have normal lifecycle functions.

    This transparent activity calls the gallery intent onCreate(), it gets everything returned like normal in its onActivityResult and you will be able to pass the information returned back to the rest of the app like normal. finish() is inside of the onActivityResult method, so the user never even notices that a transparent activity was called.

    Update copied from from comments:

    Activity A calls Activity B via normal intent. Activity B has no xml and runs onCreate like this

    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 
        //setContentView(R.layout.dialogpopper); 
    
        Intent intent = new Intent(Intent.ACTION_PICK); 
        intent.setType("image/*"); startActivityForResult(intent, 0);
    
    }//end onCreate 
    

    and when Activity C is finished it calls the onActivityResult of Activity B

提交回复
热议问题