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.32k
    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 :

    1. 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 -

    1. if (!isInMultiWindowMode()) {
    2. someView.setText("Please enable multi window mode.");
    3. } else {
    4. someView.setText("Enabled...");
    5. }

    declare activity dimensions in manifest :

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

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

    1. Intent intent = new Intent(this, MyAdjacentActivity.class);
    2. intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK);
    3. 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 :

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

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

    1. Rect mBounds = new Rect(600, 400, 200, 0);
    2.  
    3. ActivityOptions mOptions = ActivityOptions.makeBasic();
    4. mOptions.setLaunchBounds(mBounds);
    5.  
    6. Intent intent = new Intent(this, MyLaunchBoundsActivity.class);
    7. startActivity(intent, options.toBundle());

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: