android - Execution order of OnActivityResult and OnResume -
i understand onactivityresult should called before onresume in activity that's not happening me. i'm finding gets called before onresume, , before onstart. sample code below, i'm breakpointing relevant methods see what's happening. what's going on?
activity 1
using system; using system.collections.generic; using android.app; using android.content; using android.runtime; using android.views; using android.widget; using android.os; using android.content.pm; namespace lifecycletest { [activity(mainlauncher = true)] public class activity1 : activity { protected override void oncreate(bundle bundle) { base.oncreate(bundle); this.setcontentview(resource.layout.main); this.findviewbyid<button>(resource.id.button1).text = "start activity 2"; this.findviewbyid<button>(resource.id.button1).click += button_click; } void button_click(object sender, eventargs e) { intent = new intent(this, typeof(activity2)); this.startactivityforresult(i, 1); } protected override void onstop() { base.onstop(); } protected override void onresume() { base.onresume(); } protected override void onstart() { base.onstart(); } protected override void onactivityresult(int requestcode, result resultcode, intent data) { base.onactivityresult(requestcode, resultcode, data); } } }
activity 2
using system; using system.collections.generic; using android.app; using android.content; using android.runtime; using android.views; using android.widget; using android.os; using android.content.pm; namespace lifecycletest { [activity] public class activity2 : activity { protected override void oncreate(bundle bundle) { base.oncreate(bundle); this.setcontentview(resource.layout.main); this.findviewbyid<button>(resource.id.button1).text = "return result"; this.findviewbyid<button>(resource.id.button1).click += button_click; } void button_click(object sender, eventargs e) { this.setresult(result.ok); this.finish(); } } }
layout
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:minwidth="25px" android:minheight="25px"> <button android:text="button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/button1" /> </linearlayout>
this happens when activity set "singleinstance". activity singleinstance. try removing it.
Comments
Post a Comment