Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to declare dimension of activity and how to start launch bounds activity ?

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 1.29k
    Comment on it

    Hi, Android 7 i.e nougat supports multi window mode to open more than one screens at a time

    With help of this flag one activity can be open adjacent to another activity.

    Require jdk : 1.8 or higher

    Require sdk : 24 nougat

    Require dependency :

    compile 'com.android.support:appcompat-v7:24.0.0-beta1'
    

    Example :

    First of all check in your activity that is device support multi window or not -

    if (!isInMultiWindowMode()) {
        someView.setText("Please enable multi window mode.");
    } else {
        someView.setText("Enabled...");
    }

    declare activity dimensions in manifest :

    <activity
        android:name="com.android.MyAdjacentActivity"
        android:taskAffinity="" />

    and in your main activity we have to use these flags :

    Intent intent = new Intent(this, MyAdjacentActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

     

    Now Launch bounds activity that means we can declare some area bounds into its intent and activity will be run in specified area bound.

    declaration in manifest :

    <activity
        android:name="com.android.MyLaunchBoundsActivity"
        android:taskAffinity="" />

    and start activity by passing launch bound as a bundle in intent :

    
    Rect mBounds = new Rect(600, 400, 200, 0);
    
    ActivityOptions mOptions = ActivityOptions.makeBasic();
    mOptions.setLaunchBounds(mBounds);
    
    Intent intent = new Intent(this, MyLaunchBoundsActivity.class);
    startActivity(intent, options.toBundle());

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: