[英]How to perform back button action in another app?
我想要简单的应用程序从当前可见活动中取消堆栈中的活动...如何实现应用程序在后台运行并在正在运行的应用程序中关闭活动?
假设这些是您自己的活动,则需要对要关闭的活动声明一个动作,然后从另一个应用程序调用该动作。 关闭活动将在onNewIntent()中得到通知,您可以在其中检查操作并完成调用
在可关闭的活动中:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if ("action.action.myactionstring".equals(intent.getAction())) {
finish();
}
}
在封闭活动中
<activity android:name=".CloseableActivity" >
<intent-filter>
<action android:name="action.action.myactionstring" />
...
</intent-filter>
</activity>
在其他活动中
Intent intent = new Intent("action string");
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
您是否尝试了finish(); 命令? 更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.