安卓意图默认值-检测和清除[英] Android Intent defaults - detect and clear

本文是小编为大家收集整理的关于安卓意图默认值-检测和清除的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

是否有一种方法可以检测到手机有一个默认应用程序,例如android.intent.action.SEND?

有没有办法通过代码清除默认应用程序?

我想为用户提供一个选择以删除默认值或至少显示屏幕,请告诉他们如何手动进行操作,如果我可以检测到它.

推荐答案

看一下 Packagemanager .有了它,您可以确定如何通过分辨率(意图)处理意图.看起来像清除偏好的方法(clearpackagepreferredactivities)仅适用于您自己的软件包.

其他推荐答案

使用默认值2步检测:

PackageManager.queryIntentActivities要获得所有意图的活动,PackageManager.resolveActivity解决.

如果已解决的一个在queryIntentActivities返回的列表中,则将使用"对话框",因此设置了"默认"活动.

本文地址:https://www.itbaoku.cn/post/102452.html

问题描述

Is there a way to detect that a phone has a default application chosen for an intent such as android.intent.action.SEND ?

Is there a way to clear the default application via code?

I'd like to give the user an option to remove the default or at least show a screen telling them how to do it manually, if I can detect it.

推荐答案

Take a look at PackageManager. With it, you can determine how an Intent will be handled with resolveActivity(intent). It looks like the method for clearing the preference (clearPackagePreferredActivities) only works on your own package.

其他推荐答案

Use 2-step detection of defaults:

PackageManager.queryIntentActivities to get all activities for Intent, PackageManager.resolveActivity to get resolved.

If resolved one is in the list returned by queryIntentActivities, then there will be no "Complete action using" dialog, thus "default" activity was set.