[英]Application should not display in recent app list after finish the activity if app was not displaying recent app list previously
Step 1- Application is not exist in recent app list (App has been removed from recent app list). 步骤1-应用程序在最近的应用程序列表中不存在(应用程序已从最近的应用程序列表中删除)。
Step 2- As soon as I got notification open IncomingCall activity, User accept the call. 第2步 - 一旦我收到通知,打开IncomingCall活动,用户接受呼叫。
Step 3- User click on disconnect button finish the IncomingCall activity. 步骤3-用户单击断开连接按钮完成IncomingCall活动。
Problem- Application showing in recent app list even app was not in recent app list previously. 问题 - 应用程序显示在最近的应用程序列表甚至应用程序之前不在最近的应用程
Manifest entry 清单入口
<activity
android:name=".activities.IncomingCall"
android:excludeFromRecents="true"
android:launchMode="singleTop"
android:screenOrientation="portrait" >
</activity>
In the activity using 在活动中使用
public void onClick(View v) {
switch (v.getId()) {
case R.id.onCallDisconnectButton:
phoneCallBaseClass.disconnect();
IncomingCall.this.finish();
break;
}
}
And also I have tried below link but it will work when app already exist in background 而且我也试过下面的链接,但它将在app已经存在于后台时工作
Remove app from recent apps programmatically 以编程方式从最近的应用删除应用
OR Is there any other way to show incoming call view So that it will not persist in history. 或者是否有任何其他方式来显示来电视图以便它不会在历史记录中持续存在。
you can take example of any VoIP calls app- 你可以举例说明任何VoIP电话应用
Remove app from recent app list after that incoming call came, user disconnect the call activity(IncomingCallActivity) would not be exist in recent app list. 在来电来电后,从最近的应用列表中删除应用,用户断开呼叫活动(IncomingCallActivity)将不会存在于最近的应用列表中。 But in My case activity persist in recent app list after disconnecting the call.
但在我的案例中,在断开呼叫后,活动在最近的应用列表中仍然存在。
Thanks 谢谢
Add 加
android:excludeFromRecents="true"
to the activity tag of your launcher activity in AndroidManifest.xml file 到AndroidManifest.xml文件中的启动器活动的活动标签
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:excludeFromRecents="true">
....
</activity>
Thanks God, I got answer after wondering a week. 感谢上帝,我想知道一周之后得到了答案。 Add singleInstance attribute along with exclude from recent.
添加singleInstance属性以及从最近的排除。 It was a bug in 5.0 now has been resolved in 5.1
这是5.0中的一个错误,现在已经在5.1中解决了
<activity
android:name="activityName"
android:excludeFromRecents="true"
android:launchMode="singleInstance"
>
</activity>
As per you needs, finishAndRemoveTask() is the new API that as per the documentation 根据您的需要, finishAndRemoveTask()是根据文档的新API
Finishes all activities in this task and removes it from the recent tasks list.
完成此任务中的所有活动,并将其从最近的任务列表中删除。
if(android.os.Build.VERSION.SDK_INT >= 21)
{
finishAndRemoveTask();
}
else
{
finish();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.