Intent window = new Intent(mContext, popup.class);
window.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_REORDER_TO_FRONT|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
mContext.startActivity(window);
我的活动开始和日志
onCreate
onStart
onResume
现在我想阻止我的活动我用这个
开始我的活动moveTaskToBack(true); //i don't know if this best way to stop an activity
and the Log
onPause
onStoped
的onDestroy不叫
现在我想重新开始同一个活动,我使用
Intent window = new Intent(mContext, popup.class);
window.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_REORDER_TO_FRONT|Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
mContext.startActivity(window);
这里它不是重新启动活动及其做出新的
onCreate
onStart
onResume
这是我在清单中的活动
<activity
android:name=".activity.popup"
android:taskAffinity=".MyDialog"
android:configChanges="orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.FloatingWindow.Popup"
android:windowSoftInputMode="adjustResize|stateAlwaysHidden"
tools:ignore="ExportedActivity"
>
</activity>
注**如果我使用launchMode singleInstance
其重新启动,而不是创造新的活动,但这里的问题我不能实例相同的活动不同的数据
通过调用'Intent window = new Intent(mContext,popup.class)',即使没有标志,它也会创建一个新的活动实例,它明确声明它是新的任务并且与发送的任务无关背部。因此,您的*新*活动会经历基本的Android生命周期:onCreate,onStart等。 – NitroNbg
@NitroNbg所以解决方案我该如何启动停止的活动? – medo
使用finish()停止 – DKV