How to check if my application is installed by default or not in android?

I want to check if my application is installed as the default application for Intents, which I process inside my application.

As an example, which supports several applications, it allows you to open the specified file format. I need to make my application as the default application from my code. How can I make my application the default (from code)? Can someone help me?

At the very least, I would like to check this when starting my application and redirect the user to fill in some information if my application is not installed as the default value on the device.

+6
android
source share
3 answers

As far as I know, this is not possible. This dialog is processed by the system - your application will be launched only if the user selects your application from the list.

Allowing this behavior will affect the user's ability to control their applications by default, and from a technical point of view it will mean a process, and its memory should be allocated to each application in the list each time such a list appears.

+3
source share

To check if the application is the default for a specific category of objects - How to determine if my application is installed by default as a user?

0
source share

You can use this method:

public static boolean isOurAppDefault(Context context) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com")); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(browserIntent,PackageManager.MATCH_DEFAULT_ONLY); String defaultBrowserPkg = null; if (resolveInfo != null) { if (resolveInfo.activityInfo != null) { defaultBrowserPkg = resolveInfo.activityInfo.packageName; } } return TextUtils.equals(context.getPackageName(), defaultBrowserPkg); } 

This is true for some editors or browsers. Otherwise, use different Uri data for the intent.

0
source share

All Articles