Skip to main content
Samsung Developer Program

Fundamental Edge Functionality

How to integrate basic Look Edge functionality for all types of Edge apps

 

Certain Look components must be available and Edge functionality must or can be integrated into all types of Edge panel and feed apps: Single Plus panel apps, Single panel apps, feed apps, and Immersive panel apps (deprecated).

Initializing Look and Handling Exceptions

Your app must initialize Look Edge functionality so your users can use your Edge app. Initialization requires: suitable JAR files, appropriate dependencies, a specific manifest permission, and integrating the Slook.initialize() method.  Your Edge app must also handle initialization exceptions.

The Slook.initialize() method:

  • Checks if the device is a Samsung device.
  • Checks if the device has the Look package.
  • If the user device supports your Edge app, Look is initialized.
  • If not supported an exception error is thrown, which your Edge app must handle (see below).
     

To initialize Look:

  1. For your type of development environment, ensure the proper JAR files are listed in your Edge project'slibs directory:
  • For all development environments, ensure the look-[version].jar file is listed.
  • When not using the Edge simulator, ensure the Slook_[version].jar file is listed and ensure theedge_simulator_[version].jar file is not listed.
  • When using the Edge simulator, ensure theedge_simulator_[version].jar file is listed and ensure the Slook_[version].jar file is not listed.
    For more details about using the Edge Simulator, see Edge Simulator.
     
  1. Add appropriate dependencies for your Edge app to the build.gradle.
dependencies{ compile fileTree(include: '*.jar', dir: 'libs')
...
}

 

  1. In the AndroidManifest.xml, specify the following permission.

<uses-permission android:name= "com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>

We strongly recommend that you always specify the permission.   On certain user devices, it is required.

  • Required for user devices with Android 4.4.2 (KitKat) and above.
    If not specified, a SecurityException is thrown and your Edge app will not work.
  • Not required for user devices with an OS prior to Android 4.4.2 (KitKat).
    If not specified, no exception is thrown and your Edge app works properly.
     
  1. Execute the following example code to initialize Look functionality, and manage initialization exceptions by displaying text to the user if their device does not support the Edge app.
Slook slook = new Slook(); 
LinearLayout l = (LinearLayout) findViewById(R.id.information); 

try { 
    slook.initialize(this); 
} catch (SsdkUnsupportedException e) { 
    e.getType();
    l.addView(createTextView(e.toString())); 
    return; 
}

 

If the user device does not support Look functionality, an SsdkUnsupportedException exception is thrown, which your Edge app must handle.  Best practices include terminating gracefully (for example, display a text message to the user).

VENDOR_NOT_SUPPORTED

The device is not a Samsung device; it does not support Look functionality.

DEVICE_NOT_SUPPORTED

The device is a Samsung device, but it is not a Samsung Edge device and it does not support Look functionality.

 

 

The following example code initializes Look and shows how to handle initialization exceptions.

Slook slook = new Slook();
LinearLayout l = (LinearLayout) findViewById(R.id.information);

try { 
    slook.initialize(this); 
} catch (SsdkUnsupportedException e) { 
    /* What to do if the device does not support your Edge app. */
    l.addView(createTextView(e.toString()));
    return; 
} 

if (slook.isFeatureEnabled(Slook.COCKTAIL_PANEL)) { 
    /* What to do when the device supports Edge Single Plus panel apps, Edge Single panel apps, 
    and/or Edge feed apps. */
    ...
} 

 

Checking Device Support for Your Edge App

The following types of Edge apps are supported () by Samsung Edge devices.

  Note Edge S6+ or S6
OS < M
S6+ or S6
OS M or >
S7 S8 S8+
Single Plus panels    
Single panels      
Immersive panels          
Feeds      

 


Your Edge app must call initialize() to initialize Look, which may or may not be successful:

  • When an initialization exception is thrown, your Edge app (of any type) cannot run on the user device because the user device does not support Look Edge functionality.   Your app must properly handle it (for example, by terminating gracefully).
  • When initialization is successful, your Edge app may or may NOT run because the user device does not support your specific type of Edge app.  Therefore, your app must determine whether the user device supports your type of Edge app.
     

Your app can use the isFeatureEnabled() method to determine whether the user device supports the following groups of Edge app types:

  • Edge Single Plus panel apps, Edge Single panel apps, and/or Edge feed apps
  • Edge Immersive panel apps (deprecated)

Your Edge Immersive panel app can use isFeatureEnabled(Slook.COCKTAIL_BAR).  A true result definitely indicates that the user device supports Edge Immersive panel apps.  

Your Edge app of the other types can useisFeatureEnabled(Slook.COCKTAIL_PANEL)
A true result indicates that the user device supports 1 or more of the other types of Edge apps are supported.   If your Edge app's configuration file is properly set for your type of Edge app, only users with Samsung Edge devices and OS that support your type of Edge app will be able to download and run your Edge app.  

Therefore, after getting a true result from the isFeatureEnabled() method call for your type of Edge app, it will be able to run on the user device.  If your Edge app type's isFeatureEnabled() returns a false result, your app must properly handle it (for example, by terminating gracefully).
 

The following example COCKTAIL_PANEL code checks device support for Edge Single Plus panel apps, Single panel apps, and/or Edge feed apps.

if (slook.isFeatureEnabled(Slook.COCKTAIL_PANEL)) { 
    /* What to do when the device supports Edge Single Plus panel apps, Edge Single panel apps, and/or Edge feed apps. */ 
    ...
}

 

The following example COCKTAIL_BAR code checks device support for Edge Immersive panel apps.

if (slook.isFeatureEnabled(Slook.COCKTAIL_BAR)) { 
    /* What to do when the device supports Edge Immersive panels. */
    ...
}

 

Edge App Layout Resources

For all types of Edge panel and feed apps, Android vertical layout resources must be specified to support the portrait device display mode. To support displaying your Edge panels and feeds when the device is re-oriented to landscape mode, specify horizontal layout resources. Edge will then manage the proper display in each device orientation mode.

If horizontal layout resources are not added, vertical layout resources will be used when the device is in landscape mode. Your Edge panel or feed will not adjust when the device screen is re-oriented, which may result in odd displays (such as upside-down text) or critical errors (such as UI buttons not being displayed). 

The following example code shows how to specify vertical layout resources.

/res/layout/sample_panel.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="120dp"
    android:background="@android:color/holo_orange_light"
    android:orientation="vertical" />

The following example code shows how to specify horizontal layout resources:

/res/layout-land/sample_panel.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="horizontal" >

<LinearLayout
    android:layout_width="120dp"
    android:layout_height="match_parent"
    android:background="@android:color/holo_orange_light"
    android:orientation="horizontal" /> 

 

Edge App Layout

Your Edge app must specify a layout for your Edge app screen in XML and save it in the projectres/layout/ directory.

Creating an Edge panel or feed layout is similar to using Android layouts. However, Edge layouts are based on RemoteViews, which do not support all Android layout classes. Edge RemoteView objects support the following layout classes:

  • FrameLayout, LinearLayout, RelativeLayout, GridLayout
  • Button, ImageButton
  • ImageView, ProgressBar, TextView, ViewFlipper, ListView
     

The example code defines an initial layout for your Edge app.

RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.edge_panel);
setPendingIntent(context, rv);
for (int i = 0; i < cocktailIds.length; i++) { cocktailBarManager.updateCocktail(cocktailIds[i], rv);
}

 

For more details, see Android RemoteViews.

When update RemoteViews has already been inflated, use the GUI performance RemoteView.reapply method. 

 

Specifying Edge Apps for the Galaxy Apps Store

APK metadata can enable Galaxy Apps to properly promote your Edge Single Plus panel, Edge Single panel, and Edge feed apps (including putting them in the Edge Store).  However, Android apps are not promoted as Edge apps, even when an Android app: has an Edge Immersive panels as a display panel, or has been combined with other Edge panel and feed apps. 

When your Edge app(s) are in an Edge APK being distributed via the Galaxy Apps store, your Edge APK must specify a<metadata> element in the AndroidManifest.xml that indicates the type of your Edge app(s).  

Caution:  When your Edge app(s) in an Android APK being distributed via the Galaxy Apps store, the Android APK must NOT specify this metadata.
 

When your Edge apps are to be distributed via the Galaxy Apps store:

  • Specify an android:name of com.samsung.android.cocktail.mode
  • Specify an android:resource of the proper Edge app type:
     
    Edge_single_plus Edge Single Plus panel apps
    edge_single Edge Single panel apps
    edge_feeds Edge feed apps

     

The following example code shows how to specify an Edge Single Plus panel app for Galaxy Apps store distribution:

/AndroidManifest.xml 

<meta-data
    android:name="com.samsung.android.cocktail.mode"
    android:value="edge_single_plus" /> 

 

Updating Edge App Items

Each item in an Edge panel or feed is assigned a unique ID by Look. Your app can instruct Edge to refresh any item's content via its ID in response to an Edge update broadcast for periodic refreshing of item content, when an Edge panel or feed is enabled or its visibility is changed to displayed, for your app's own purposes, or when your app's user initiates updating content on demand.
 

Updating via Pull-to-Refresh

This functionality is available in Slook SDK v1.4.0 and later.

You can easily add pull-to-refresh interactions to your Edge Single Plus panel apps by using the setOnPullPendingIntent method.  After setting a pull-to-refresh target view, it will be added to SwipeRefreshLayout, and it send a registered pendingIntent with the pulling gesture on the target view. The target view of the SetOnPullPendingIntent method is available for the Edge Single Plus panel app contentView, but not for its helpView.

Intent refreshintent = new Intent(ACTION_PULL_TO_REFRESH);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0xff, refreshintent, PendingIntent.FLAG_UPDATE_CURRENT);
SlookCocktailManager.getInstance(context).setOnPullPendingIntent(cocktailIds[0], R.id.remote_list, pendingIntent);

 

Long-Click Actions

This functionality is available in Slook SDK v1.4.0 and later.

Similar  to using the RemoteViews.SetOnClickPendingIntent method, you can set a pending intent to launch with long clicking in your Edge Single Plus panel apps by using the setOnLongClickPendingIntent method.

RemoteViews stateView = new RemoteViews(context.getPackageName(), R.layout.long_click_state_layout);
SlookCocktailManager.getInstance(context).setOnLongClickPendingIntent(stateView, R.id.state_btn1, pendingIntent);

 

If the long click target view is using collections (for example, ListView and GridView), you can set a pendingIntent template instead set them on each items of collections individually.  The setOnLongClickPendingIntentTemplate works based on AdapterView.setOnItemLongClickListener.  It could be restricted on some types of collection widgets (such as, StackView and AdapterViewFlipper).

RemoteViews remoteListView = new RemoteViews(context.getPackageName(), R.layout.remote_list_view);
SlookCocktailManager.getInstance(context).setOnLongClickPendingIntentTemplate(remoteListView, R.id.remote_list, templatePendingIntent);

 

To use a pendingIntent template, you must set fillInIntent on its item views, and it should be set on the root view of item layout.

private class SampleRemoveViewFactory implements
RemoteViewsService.RemoteViewsFactory {
    @Override
    public RemoteViews getViewAt(int id) {
        RemoteViews itemView = new RemoteViews(getPackageName(), R.layout.remote_list_item);
        ...
        itemView.setOnClickFillInIntent(R.id.item_root, intent); return itemView;
    }
}

 

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/item_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    ... 
</FrameLayout>

 

  • Was this article helpful?