我有一个应用程序,称为“App1”。在我的 App1 中,我调用相机应用程序。
intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName("com.android.camera","com.android.camera.Camera"));
startActivity(intent);
之后,我使用 FileObserver 来监听用户是否拍照。当这种情况发生时,我打电话
Context ctx = App1.this.getApplicationContext();
Intent j = new Intent(ctx, App1.class);
j.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
j.putExtra("type", 1);
startActivity(j);
它有效,我的意思是它让我的应用程序前置我如何离开它,但是我需要传递一个整数,称为“类型”。我想,我的应用程序将调用“onResume()”,但我怎样才能获得额外的整数。这种类型的传递在我的应用程序中没有做任何事情。
onCreate方法中有BundlesavedInstanceState,但onResume方法中没有这个东西。所以,我需要你的帮助来解决这个问题。提前致谢。
你需要覆盖Activity.onNewIntent() http://developer.android.com/reference/android/app/Activity.html#onNewIntent%28android.content.Intent%29 method.
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
After onNewIntent()
被称为,正常的onResume()
生命周期将随之而来。或者,您可以将代码写入onNewIntent()
itself.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)