安卓:startActivityForResult总是得到0的结果code?结果、startActivityForResult、code

2023-09-06 06:38:09 作者:猫性小公主

由于某些原因,当我使用电话,结果总是返回0。所有我做的是弹出选择框,然后一旦做出选择,用户点击后退按钮。有谁知道我可以做什么错误呢?

调用活动:

 意向书I =新意图(这一点,Selection.class);Log.d(前端,启动活动);startActivityForResult(I,选择); 

调用活动:

  bundle.putStringArray(选择,selected_array);意图resultIntent =新的Intent();resultIntent.putExtras(包);的setResult(RESULT_OK,resultIntent);完(); 
清风网络助手app下载 清风网络助手下载安装官方app v1.0.0 嗨客手机站

有什么建议?如果我有终点()调用,它给了我以下内容:

  W / ActivityManager(1030):为重复{HistoryRecord 44802c90 com.android.TVitter / .Selection}结束请求 

解决方案

好吧不熄火的我。我花了两个小时来调试这个:(只是把它写下来,这样别人就不​​会犯这个愚蠢的错误,我不得不把一个OK按钮,然后处理事件,而不是让用户preSS的回到手机上的按钮。这是一个明显的事情,但由于某种原因,我错过了......

For some reason, when I use the call, the result is always returned as 0. All I am doing is popup the selection box and then once the selection is made, the user hits the back button. Does anyone know what mistake I could be doing?

CALLING ACTIVITY:

Intent i = new Intent(this, Selection.class);
Log.d("Front-End", "Launching Activity");
startActivityForResult(i, SELECTION);

INVOKED ACTIVITY:

bundle.putStringArray("selections", selected_array);
Intent resultIntent = new Intent();
resultIntent.putExtras(bundle);
setResult(RESULT_OK, resultIntent);
finish();

Any suggestions? If I include the finish() call, it gives me the following:

W/ActivityManager( 1030): Duplicate finish request for HistoryRecord{44802c90 com.android.TVitter/.Selection}

解决方案

Ok don't flame at me now. It took me two hours to debug this :( Just writing it down so that others won't make this stupid mistake. I had to put an "OK" button and then handle the event instead of letting the user press the "Back" button on the phone. It was an obvious thing but for some reason I missed it...