Advertisement
Guest User

Freeform mode (Android 7.0 - 8.1)

a guest
Jun 17th, 2020
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. // From android.app.ActivityManager.StackId
  2. final int FREEFORM_WORKSPACE_STACK_ID = 2;
  3.  
  4. ActivityOptions options = ActivityOptions.makeBasic();
  5.  
  6. // Note: Android 8.x broke setLaunchBounds(), and as a result,
  7. // doesn't actually apply the bounds specified in the Rect.
  8. // The app will still launch in a freeform window, though.
  9. options.setLaunchBounds(new Rect(0, 0, 500, 500));
  10.  
  11. try {
  12.     Method method = ActivityOptions.class.getMethod("setLaunchStackId", int.class);
  13.     method.invoke(options, FREEFORM_WORKSPACE_STACK_ID);
  14. } catch (Exception e) { /* handle exception */ }
  15.  
  16. // Now, call startActivity(intent, options.toBundle());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement