简体   繁体   English

如果应用程序之前未显示最近的应用列表,则应用程序不应在完成活动后显示在最近的应用列表中

[英]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.

相关问题 在Activity上调用finish()时从最近的应用程序列表中排除该应用程序 - Excluding the application from recent app list on invoking finish() on Activity 从最近的应用程序列表中滑动活动状态后还能保留活动状态吗? - Preserve activity state after swiping it from recent app list? 活动会从最近的应用列表中删除该应用 - An Activity removes the app from recent apps list 从最近的应用列表中删除一个应用 - Removing an application from the recent app list 应用被杀死后仍保留在“最新列表”中 - App remains in “most recent list” after killing it 从最近的应用程序列表中删除后,Android应用程序进程未终止 - Android app process not killed after removed from recent app list 防止活动从android中的最新应用列表运行 - Prevent activity run from recent app list in android 当应用程序从 android 的最近列表中删除时,会调用哪个活动? - Which activity is called when app removed from recent list in android? 如何在没有完成活动的情况下从最近的列表返回上一个应用 - How to back to last app from recent list without finishing activity Android-从操作系统的应用程序“最近使用的应用程序”列表中启动的活动 - Android - Activity launched from the OS's app recent apps list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM