How can I determine which application is the default application for a certain action? For example I want to know which application is used for making calls or receiving text me
resolveActivity does something along the lines of what you're looking for. From the official docs:
Determine the best action to perform for a given Intent. This is how resolveActivity(PackageManager) finds an activity if a class has not been explicitly specified.
And here's an example:
Intent i = (new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
PackageManager pm = context.getPackageManager();
final ResolveInfo mInfo = pm.resolveActivity(i, 0);
Toast.makeText(
context,
pm.getApplicationLabel(mInfo.activityInfo.applicationInfo),
Toast.LENGTH_LONG
).show();
Note that the return value is somewhat fuzzy:
Returns a ResolveInfo containing the final activity intent that was determined to be the best action. Returns null if no matching activity was found. If multiple matching activities are found and there is no default set, returns a ResolveInfo containing something else, such as the activity resolver.
Use Intent Filters and resolveActivity().
From Android's documentation on Intent Filters:
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type
ComponentName compName = sendIntent.resolveActivity();
And here's the documentation on ComponentName