Reputation: 31963
I have the normal 'Phone' dialer and I have new 'Dialer' app. Now if I check the "Use by default for this action" and click on the 'Dialer' app then every time when I press the phone button the 'Dialer' app will be started automatically. But how can I change this in code ?
Where this preference is stored ?
And how is this mapped ? is this is mapped by an android action intent string ?
for example the Intent.ACTION_CALL is paired with some application for example the 'Dialer' app to be the default app that will be started every time the Intent.ACTION_CALL it is raised...
Thanks
Upvotes: 5
Views: 6475
Reputation: 1
@RequiresApi(api = Build.VERSION_CODES.M)
private void chnagedialer() {
TelecomManager systemService = this.getSystemService(TelecomManager.class);
if (systemService != null && !systemService.getDefaultDialerPackage().equals("com.android.contacts")) {
startActivity((new Intent(ACTION_CHANGE_DEFAULT_DIALER)).putExtra(EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME,"com.android.contacts" ));
}
}
Upvotes: 0
Reputation: 6829
Starting from API 21 you can use next intent to ask user to be a default dialer:
Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER)
.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, getPackageName());
if (intent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(intent, REQUEST_CODE_SET_DEFAULT_DIALER);
} else {
Log.w(getLocalClassName(), "No Intent available to handle action");
}
Upvotes: 1
Reputation: 1358
You can't change default applications using a app but you can referr via intent to the settings page of an app to set the defaults
Intent i = new Intent(android.provider.Settings.Aplications);
startActivity(i);
or something like this
Upvotes: 0