javaandroidandroid-studiovideoandroid-video-player

How to ask for the permission to become Default Video Player in Android?


I am developing a video player app and I want my app to Prompt for the permission to be the default Video Player to be the default handler of video play. I know it has to be something like the default handler:

Intent setSmsAppIntent =
    new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
setSmsAppIntent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
    getPackageName());
startActivityForResult(setSmsAppIntent, your-result-code);`

source: Android Docs

But I don't know the Action I have to give to the Intent as action. Can someone please help me? Thanks in advance.


Solution

  • It's not possible, developers can't call intent to change default Video player only users can do that on their device. Its only possible for SMS service.

    However, for video player you can register app for video player in AndroidManifest.xml and call the function which opens settings to change default apps using the following code:

    Intent intent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);