基本上我正在从父(MainActivity)演示中调用一个新活动(ExplorerActivity),其中包含伪代码......
public class MainActivity extends Activity {
boolean isLoggedin=false;
onCreate(){
Print(isLoggedin)
isLoggedin=true;
}
public boolean onOptionsItemSelected(MenuItem item) {
Intent i = new Intent(MainActivity.this, ExplorerActivity.class);
startActivityForResult(i, 0);
return true;
}
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
Log.e("Teste", "Mainactivty: onActivityResult was called!!");
xTaskThread = new xTaskThread();
xTaskThread.start();
}
------------ ExplorerActivity -----
public class ExplorerActivity extends ListActivity {
Intent i = getIntent();
i.putExtra("fileURL", file.getAbsolutePath());
setResult(RESULT_OK, i);
finish();
Manifest:
<activity
android:name="com.geoclient.misc.ExplorerActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
</activity>
-------------------------------------
一切正常,直到从 ChildActivity (ExplorerActivity) 返回。跟单成功:
- ExplorerActivity,完成活动... (finish())
- OnCreated 调用,printed('isLoggedin=FALSE') <---(我期望 TRUE)不应该保持变量状态?(与重新启动应用程序相同...)
- onActivityResult 调用,打印('Mainactivty:onActivityResult 被调用!!')
看起来应用程序已重新启动...我不明白..我期待回到 onResume() 并且变量处于相同状态..请让我知道我错了!(我在 Mainactivity 中使用 googlemap,不确定这是否相关..)非常感谢!