Optional Compatibility features

Modifying apps for Samsung DeX

The following section includes tips on how to add extra features to a Samsung DeX app – such as assigning an menu action to a mouse right click. For the best Desktop experience, apps should meet these optional compatibility features. However, they are not required to launch in Desktop Mode.

Samsung Mobile Browser

Follow these instructions to provide a desktop experience with the Samsung Internet Browser.

  1. By default, open web pages in “Desktop View” instead of "Mobile View"

    • User Agent String for Samsung Internet “Desktop View: Based on Chrome Linux UA with additional SamsungBrowser/$ver keyword

    Mozilla/5.0 (Linux; Android $ver; $model) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/$app_ver Chrome/$engine_ver Mobile Safari/537.36 
    ※ Current values: android_ver = 7.0 app_ver = 5.2 , engine_ver = 51.0.2704.106\
  2. Allow users to switch to mobile when needed.

    • User Agent String for Samsung Internet “Mobile View”

    Mozilla/5.0 (Linux; Android $ver; $model) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/$app_ver Chrome/$engine_ver Mobile Safari/537.36 
    ※ Current values: android_ver = 7.0 app_ver = 5.2 , engine_ver = 51.0.2704.106\
  3. Support Mouse Events

    • In Samsung DeX mode, mouse events are processed as mouse events (In mobile mode, mouse events are transferred to touch events). However, because Touchpad is a supported input device in Samsung DeX, touch events are also supported.

    • Removing mouse event listeners on touch supported browsers might limit mouse usage on your web site.

  4. Support auto-play

    • HTML < video > autoplay attribute works in Desktop Mode (not supported in mobile mode)

    <video width="320" height="240" controls autoplay> <source src="movie.ogg" type="video/ogg">

Mouse Right Click

Enabling mouse right-click allows for easier interaction with apps. For example, it can be useful for showing desktop-like action such as a contextual menu.

Figure 8: Mouse right click

If an app uses the EditTextView of the Google API, it does not need to implement additional features for using mouse right click. In EditTextview, the following actions are available:

  1. 1.

    Mouse right-click: show Contextual Menu.

  2. 2.

    Mouse left-double click on text: select the text.

If an app is not using EditTextView of the Google API, this code snippet enable mouse right click.

  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      layout_main = (RelativeLayout) findViewById(R.id.layout_main);
      registerForContextMenu(layout_main);
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
      if (v.getId() == R.id.layout_main) {
          menu.setHeaderTitle("Context Menu Test");
          menu.add(Menu.NONE, ONE, Menu.NONE, "Menu 1");
      }
      super.onCreateContextMenu(menu, v, menuInfo);
  }
  @Override
  public boolean onTouchEvent(MotionEvent event) {
      if (event.getAction() == MotionEvent.ACTION_DOWN && event.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
          layout_main.showContextMenu(event.getX(), event.getY());
      }
      return super.onTouchEvent(event);
  }

Mouse-wheel zoom

Enabling mouse-wheel zoom allows for easier interaction with apps that require Multi-Touch zoom (pinch zoom in and out) to operate efficiently. For example, maps or games. To enable Multi-Touch, an app must receive the wheel up/down eventMotionEvent.ACTION_SCROLL in Activity.dispatchTouchEvent(MotionEvent event) and apply the pinch-zoom function of the app with step by step information of the wheel scroll.

For example:final float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
- vScroll is -1.0, wheel down.
- vScroll is 1.0, wheel up.

    @Override public boolean onGenericMotion(View v, MotionEvent event) {
        int action = event.getAction();
        int actionCode = action & MotionEvent.ACTION MASK;
        for (int i = 0; i < event.getPointerCount(); i++) {
            float x = event.getX(i);
            float y = event.getY(i);
            float p = event.getPressure(i);
            int pid = event.getPointerld(i);
            if (actionCode == MotionEvent.ACTION_SCROLL) {
                float wheelX = event.getAxisValue(MotionEvent.AXIS_HSCROLL, i);
                float wheelY = event.getAxisValue(MotionEvent.AXIS_VSCROLL, i);
                SOLMain.mcNativeTouch(actionCode, wheelX, wheelY, p, pid);

                return true;
            }
        }
    }

Mouse Icon change

This allows the mouse icon to change when pointed at a clickable object. To change the mouse icon, set android:state_hovered="true" on the required views.

For example:

App/res/drawable/tw_list_selector_material_light.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_hovered="true" android:state_finger_hovered="true">
      <nine-patch android:src="@drawable/tw_list_hover_holo_light" />
    </item>

See Android's Pointer Icon , Set Pointer Icon and Resolve Pointer Icon reference guides for more details.

Mouse app scroll bar

Mouse scrolling works automatically if apps use ListView, GridView, or ScrollView / HorizontalScrollView of the Google SDK. See Android's App Scroll Bar reference guide for more details.

Keyboard shortcuts

Keyboard shortcuts provide enhanced multi-tasking usability in apps. See Android's Keyboard Input reference guide for more details.

This may include features such as:

  • Closing popups -> Esc

  • Switch between open apps -> Alt-Tab

  • Take screenshot -> Prt Sc

  • Undo/redo -> Ctrl-Z/Y

  • Cut/paste-> Ctrl-X/Y

  • Select all Ctrl-A

Drag and drop files

Drag and dropping files in Android allows you to easily move files between views. See Android Drag-Drop , Drag on listener and Drag events reference guides for more details.

Disable presentation class on Samsung DeX mode

Presentation class allows an app to show content on a secondary display. This may not be ideal for Samsung DeX apps, and can be disabled if needed. See Android's App Presentation reference guide for more details.

Disable fixed orientation for camera

If an app requires fixed orientation for camera use, it may not translate well to Samsung DeX Desktop mode. Fixed orientation for camera can be disabled, if needed. See Android's Camera reference guide for more details.

App size configuration method

You can scale the size of the app launch window from Galaxy Note 8 and S8 (based on Android 7.1.1) onwards as described below.
 

1. Adding Meta-data in the AndroidManifest.xml

The following meta-data can be used to customize the launch window size for an app in DeX mode. If the meta-data launchwidth, launchHeight is set to 0, the activity will be launched in full screen in Samsung DeX mode.

Meta Data Value Remarks
com.samsung.android.sdk
.multiwindow.dex.
launchwidth
int (dp) App launch window width
com.samsung.android.sdk
.multiwindow.dex.
launchheight
int (dp) App launch window height
 

Usage: com.samsung.android.sdk.multiwindow.dex.launchwidth

<application> 
	<meta-data
		android:name="com.samsung.android.sdk.multiwindow.dex.launchwidth"
		android:value="800"> 
</application>

Usage: com.samsung.android.sdk.multiwindow.dex.launchheight

<application> 
	<meta-data
		android:name="com.samsung.android.sdk.multiwindow.dex.launchheight"
		android:value="600"> 
</application>
 
2. Setting LaunchBounds in the code

ActivityOptions uses the setLaunchBounds API to launch an app in fullscreen mode. For example, set LaunchBounds as (0, 0, 0, 0) to launch the app in fullscreen in Samsung DeX mode. The code below demonstrates how to set the LaunchBounds.

// ex) fullscreen window          
ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchBounds(new Rect(0,0,0,0));
mContext.startActivity(intent, options.toBundle());
 
// ex) Tablet size window
ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchBounds(new Rect(200,200,1000,800));
mContext.startActivity(intent, options.toBundle());  
3. Meta-data used to set the launch window size

The following list contains details needed to configure the Android 7.1.1 + window size.

Meta-data provided by Samsung to set the maximum size of window: maxWidth, maxHeight.

<activity ...>
	<meta-data
		android:name="com.samsung.android.sdk.multiwindow.maxWidth"
		android:value="100" />
</activity>
<activity ...>
	<meta-data
		android:name="com.samsung.android.sdk.multiwindow.maxHeight"
		android:value="100" />
</activity>

Meta-data provided by Samsung to set the launch window size in dex mode: dex.launchwidth, dex.launchheight.
If we set meta-data launchwidth, launchHeight to 0, the activity will be launched in full screen in DeX mode. 

<activity ...>
    <meta-data
        android:name="com.samsung.android.sdk.multiwindow.dex.launchwidth"
		android:value="100" />
</activity>
<activity ...>
    <meta-data
        android:name="com.samsung.android.sdk.multiwindow.dex.launchheight"
        android:value="100" />
</activity>

Meta-data provided by Google to set the minimum size of window: minWidth, minHeigh.

<layout 
	android:minWidth="320dp" 
	android:minHeight="320dp"/>
</layout>

Meta-data provided by Google to set the window size: widthFraction, heightFraction.

<layout 
	android:width="320dp" 
	android:height="320dp"/>
</ layout>