Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable Picture in Picture mode programmatically

I'm making a settings activity in my Android video playback app and I want to know if it was possible to enable/disable PIP(Picture-in-Picture) mode programmatically.

To clarify I am fully aware that this setting can be change via application advanced settings or via special app access, but I want to leave that as a last resort. (If there are no other alternatives).

Further more this Activity is isolated from the video threading page itself.(Meaning the user would have to stop the video entirely before coming to this page).

Main reasons I want this is an extra reminder that this app supports this feature and also if the user forgets where to reactivate this function.

Think of it as: Adding another layer of user friendliness

like image 252
WrapItUp87 Avatar asked Sep 12 '26 12:09

WrapItUp87


1 Answers

Here is a way to check the setting:

AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
return (AppOpsManager.MODE_ALLOWED == appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_PICTURE_IN_PICTURE,
        context.getApplicationInfo().uid, context.getPackageName()));

I haven't tried setting it programmatically, but this could be a starting point for you.

like image 176
alexbtr Avatar answered Sep 14 '26 01:09

alexbtr