How to make an application default phone or Assistant handler on the device by giving user an option to make it default app

让人想犯罪 __ 提交于 2019-12-04 22:26:55

Check the documentation at: https://developer.android.com/reference/android/telecom/TelecomManager#ACTION_CHANGE_DEFAULT_DIALER

Sample code:

Intent intent = new Intent(TelecomManager.ACTION_CHANGE_DEFAULT_DIALER);
intent.putExtra(TelecomManager.EXTRA_CHANGE_DEFAULT_DIALER_PACKAGE_NAME, getActivity().getPackageName());
startActivity(intent);

You can't make it the default programmatically. The entire point is the user gets to choose the default, so they can choose what app gets their texts and calls. You may be able to do it with root, but nothing else.

By the way if your application is not a phone handler, but you still need them for functionality to work, you can try getting a waiver (see the last paragraph in the article): https://support.google.com/googleplay/android-developer/answer/9047303?hl=en so your app won't be a phone handler but still will be able to get those permissions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!