WrapItUp87
WrapItUp87

Reputation: 300

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

Upvotes: 3

Views: 2776

Answers (1)

alexbtr
alexbtr

Reputation: 3462

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.

Upvotes: 2

Related Questions