Managing applications on two screens

With current architecture in YotaPhone Applications on Color Screen are no different from Applications on EPD screen. They all have activities, fragments, etc. The only difference is what screen they are running at.

The simplest way to run your application on EPD is to use Transfer button that is located on right-bottom part of the screen:

When this button is pressed, whole task is moved to another screen.

Note: To know more about Tasks and Back Stack in Android please refer to Android documentation here: Tasks and Back Stack

But how do you do it programatically, in code? Well, there are 4 cases here:

1. Keep Activity on EPD - in this mode Activity will run on EPD only. In this mode it is impossible to move this Activity to Color screen;

2. Start Activity on EPD - in this mode Activity will start on EPD. In this mode Activity can be moved to Color screen for example when Transfer button on EPD is pressed;

3. Keep Activity on Color Screen - in this mode Activity will run on Color screen only. In this mode it is impossible to move Activity to EPD;

4. Start Activity on Color screen - in this mode Activity will start on Color screen. In this mode Activity can be moved to EPD, for example when Transfer button is pressed.

Lets go one-by-one in more detail.

1. Keep activity on EPD

This case is for Activities that are created for EPD only and not intended to be shown on color screen. For example this one:

This Activity is intended to be displayed on EPD only and as you may imagine displaying it on Color screen does not make much sense.

To run Activity in this mode you can either add special meta-data into your Activity in AndroidManifest.xml. Or you can start Activity with special flag.

Adding meta-data to manifest:

    <activity android:name=".EpdActivity">    
        <meta-data
     android:name="com.yotadevices.keep_on_epd_screen"        
     android:value="true" />   
    </activity>

Starting Activity with special flag:

    Intent intent = new Intent(FrontActivity.this, EpdActivity.class);
    EpdIntentCompat.setEpdFlags(intent, EpdIntentCompat.FLAG_ACTIVITY_KEEP_ON_EPD_SCREEN);
    startActivity(intent);

For this case there is one exception though: if android:launchMode="singleInstance" is set then this Activity can be moved to opposite screen nonetheless.

Also you should note that Activity for EPD will start in separate task, if EPD task is not created yet. If EPD task is already created, Activity will be launched in the created task.

2. Start Activity on EPD

In this case Activity will start on EPD. But this Activity can be moved to Color screen if requested. If Activity is already started, it will move whole task on EPD. This is exactly what happens when you press Transfer button on Color screen.

To run Activity in this mode you can use special flag to start Activity with:

    Intent intent = new Intent(FrontActivity.this, EpdActivity.class);
    EpdIntentCompat.setEpdFlags(intent, EpdIntentCompat.FLAG_ACTIVITY_START_ON_EPD_SCREEN);
    startActivity(intent);

3. Keep Activity on Color screen

This is same as Keep Activity on EPD, but opposite: this is for Activities that should work on Color screen only and not intended to be shown on EPD.

For example YotaHub application - Its color screen part is not intended to be shown on EPD screen. Hence it starts in this mode:

As you can see Transfer button is not available in this mode.

To run Activity in this mode you can either add special meta-data into your Activity in AndroidManifest.xml. Or you can start Activity with special flag.

Adding meta-data to manifest:

    <activity android:name=".FrontActivity">   
        <meta-data
     android:name="com.yotadevices.keep_on_front_screen"
     android:value="true" />  
    </activity>

Starting Activity with special flag:

    Intent intent = new Intent(EpdActivity.this, FrontActivity.class);
    EpdIntentCompat.setEpdFlags(intent, EpdIntentCompat.FLAG_ACTIVITY_KEEP_ON_FRONT_SCREEN);
    startActivity(intent);

For this case there is one exception though: if android:launchMode="singleInstance" is set then this Activity can be moved to opposite screen nonetheless.

4. Start Activity on Color Screen

This is same as Start Activity on EPD but for Color screen.

This is intended if you need to start Activity on Color Screen when user is currently on EPD screen. This is the same as pressing Transfer button from EPD.

To run Activity in this mode you can use special flag to start Activity with:

    Intent intent = new Intent(EpdActivity.this, FrontActivity.class);
    EpdIntentCompat.setEpdFlags(intent, EpdIntentCompat.FLAG_ACTIVITY_START_ON_FRONT_SCREEN);
    startActivity(intent);