Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
526 views
in Technique[技术] by (71.8m points)

android - onActivityResult never called

So far, I used the startActivity function with success and now that I need to use the startActivityResult, I have a problem.

When using this function, the activity I expect to be launched is launched correctly but it seems like the onActivityResult function is never called.

Here is my code in the FriendPicker activity, to lauch the MoodPicker activity:

Intent intent = new Intent(FriendPicker.this, MoodPicker.class);
startActivityForResult(intent, 2);

And here is my code in the MoodPicker activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent)
{                   
    super.onActivityResult(requestCode, resultCode, intent);

    Log.i("in OnActivityResult", "Activity Result");                        

    switch (requestCode)
    {
        case 2:             
            Log.i("in OnActivityResult", "Activity Resut 2");                

            break;
    }
}

and nothing in my logfile is written (I of course, checked that my log file was working properly and double check with a text view output).

Is there something I forgot to declare in the Manifest file?

Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had same problem and solved it: Just remove

android:launchMode="singleInstance"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...