设想
活动 A(登录)启动活动 B 然后完成();
活动 B 调用 startActivityForResult(Activity C)
活动 C 运行良好,然后在选择电话号码后退出(应该如此)
-- 返回桌面(应用停止)!
为什么没有回到Activity B的onActivityResult()?
笔记
我在活动 B 上创建了正确的 onActivityResult()。
我已经搜索并阅读了有关 startActivityForResult 的 stackoverflow 上的每一条数据。
代码单
启动活动 B 的代码:
ComponentName component = new ComponentName("com.emobiletelecom", PokeTALK.class.getName());
Intent intent = new Intent();
intent.setComponent(component);
startActivity(intent);
finish();
启动活动 C 的代码:
startActivityForResult(new Intent(this, ContactsPickerActivity.class), 2007);
代码整理Activity C:
Intent intent = new Intent();
intent.putExtra(KEY_PHONE_NUMBER, contactNumber);
setResult(RESULT_OK, intent);
finish();
enter code here
日志
04-23 16:32:27.382: I/ActivityManager(28158): START
{cmp=com.emobiletelecom/com.codinguser.android.contactpicker.ContactsPickerActivity} from pid 30108
04-23 16:32:27.392: W/WindowManager(28158): Failure taking screenshot for (180x300) to layer 21010
04-23 16:32:27.432: V/PokeTALK(30108): onPause
04-23 16:32:27.642: I/WindowManager(28158): createSurface Window{415eefe8 com.emobiletelecom/com.codinguser.android.contactpicker.ContactsPickerActivity paused=false}: DRAW NOW PENDING
04-23 16:32:27.812: V/PhoneStatusBar(28212): setLightsOn(true)
04-23 16:32:28.042: I/ActivityManager(28158): Displayed com.emobiletelecom/com.codinguser.android.contactpicker.ContactsPickerActivity: +599ms
04-23 16:32:28.192: V/PT(30108): onStop - PokeTALK
04-23 16:33:00.292: D/dalvikvm(28212): GC_CONCURRENT freed 396K, 36% free 10580K/16391K, paused 14ms+8ms
04-23 16:33:24.102: D/dalvikvm(30108): GC_FOR_ALLOC freed 189K, 6% free 12032K/12679K, paused 52ms
04-23 16:33:24.122: I/dalvikvm-heap(30108): Grow heap (frag case) to 13.159MB for 1390096-byte allocation
04-23 16:33:24.232: D/dalvikvm(30108): GC_CONCURRENT freed 33K, 6% free 13355K/14087K, paused 4ms+4ms
04-23 16:33:24.341: D/dalvikvm(30108): GC_FOR_ALLOC freed 0K, 6% free 13356K/14087K, paused 34ms
04-23 16:33:24.351: I/dalvikvm-heap(30108): Grow heap (frag case) to 14.452MB for 1390096-byte allocation
04-23 16:33:24.522: D/dalvikvm(30108): GC_CONCURRENT freed <1K, 6% free 14713K/15495K, paused 18ms+5ms
04-23 16:33:27.342: W/WindowManager(28158): Failure taking screenshot for (180x300) to layer 21015
04-23 16:33:27.392: W/NetworkManagementSocketTagger(28158): setKernelCountSet(10005, 1) failed with errno -2
04-23 16:33:27.442: I/WindowManager(28158): createSurface Window{41614cd0 com.android.launcher/com.android.launcher2.Launcher paused=false}: DRAW NOW PENDING
04-23 16:33:27.532: W/InputManagerService(28158): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@413fbdb0 (uid=10040 pid=30108)
04-23 16:33:28.292: W/NetworkManagementSocketTagger(28158): setKernelCountSet(10040, 0) failed with errno -2