Return to Activity after action completed in Android?

后端 未结 3 456
难免孤独
难免孤独 2020-12-07 01:21

When I start the SMS application using the following methods -- everything works fine up until the point where the message is sent. When I send the message -- it never navig

3条回答
  •  孤城傲影
    2020-12-07 01:40

    You were wrong, perhaps you may not have noticed that you had returned to the calling activity. You have to supply a request code when calling a subactivity. INVITE_COMPLETED sounds a bit like it could represent a result code. Result codes like RESULT_OK and RESULT_CANCELED are predefined finals of the Activity class. If you use

    startActivityForResult(intent, MY_REQUEST_CODE);
    

    you can then override onActivityResult() and catch that request code (which is self defined in the starting activity) there. This is what it looks like:

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == MY_REQUEST_CODE) {
            if (resultCode == RESULT_OK) {
            // do something useful
            }
        }
    }
    

提交回复
热议问题