Skip to main content
Samsung Developer Program

Fundamental Edge Functionality

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

 

When building any type of Edge app, it must have the proper dependencies and permissions and properly launch itself, including determining whether or not the user device supports the specific type of Edge app.

Device Support for Your Edge App

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

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

 

Your Edge app can determine whether or not the user device supports your Edge app:

  • Call initialize() to determine whether or not the user device supports Look Edge functionality by: 
    • Determining if the user device is a Samsung Edge device.
    • Determining if the device has the Look package.
       
  • If the user device does not support Look Edge functionality:
    • No type of Edge app can run on the user device.
    • An exception error is thrown that your app must manage (for example, by terminating your Edge app gracefully).
       
  • If the user device does support Look Edge functionality:
    • Your type of Edge app may or may not run on the user device.
    • Call isFeatureEnabled()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)
      • After it gets the response, your Edge app will know whether or not it is supported by the user device.

 

Edge App Dependencies and Permissions

Building your Edge app requires that you specify in the IDE the appropriate JAR files and dependencies, and a manifest permission. 


When building your Edge app:

  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')
    ...
    }
  2. 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. For certain user devices, it is required.

  • Required for user devices with Android 4.4.2 (KitKat) and above.
    If not specified, aSecurityException 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.

     

Edge App Launch and Exception Management

Launching your Edge app requires that you instantiate an Slook object, specify the layout and layout resources, and determine that the user device supports your Edge app. Your Edge app must also manage exceptions.
 

  1. Instantiate anslook object and specify the layout and layout resources of your Edge app.
    For layout and layout resource details, see Fundamental Edge Functionality and Fundamental Edge Functionality.
    Slook slook = new Slook(); 
    LinearLayout l = (LinearLayout) findViewById(R.id.information); 
    
  2. Call the initialize() method to determine whether or not the user device supports Edge Look functionality, and manage exceptions by displaying text to the user if their device does not support the Edge app.
    try { 
        slook.initialize(this); 
    } catch (SsdkUnsupportedException e) { 
        e.getType();
        l.addView(createTextView(e.toString())); 
        return; 
    }
    1. If the user device does not support Look functionality:
      1. An SsdkUnsupportedExceptionexception is thrown, which your Edge app must manage. 
        In the sample code above, the variable e contains the result of the ssdkUnsupportedException.getType() method:
         
        VENDOR_NOT_SUPPORTED

        The device is not a Samsung device and 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.

      2. For either result, your Edge app cannot run on the user device. Best practices include terminating gracefully (for example, by displaying a text message to the user).

    2. If the user device does support Look functionality, your app must determine whether or not the user device supports your specific type of Edge app:

      1. For Edge Immersive panel apps, use isFeatureEnabled(Slook.COCKTAIL_BAR).
        The result definitely indicates whether or not the user device supports your Edge app.  

        if (slook.isFeatureEnabled(Slook.COCKTAIL_BAR)) { 
            /* What to do when the device supports Edge Immersive panels. */
            ...
        }
        
      2. For all other types of Edge apps, useisFeatureEnabled(Slook.COCKTAIL_PANEL)
        The result definitely indicates whether or not the user device supports your Edge app.  

        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. */ 
            ...
        }
        
    3. After getting a true result from isFeatureEnabled(), your type of Edge app will be able to run on the user device.

    4. After getting a false result from isFeatureEnabled(), your type of Edge app will not be able to run on the user device, and your app must properly manage it (for example, by terminating gracefully).

 

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

If you are distributing your Edge app through the Samsung 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 panel 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 through 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 through 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 through 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 Using 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 thesetOnPullPendingIntent method. After setting a pull-to-refresh target view, it will be added to SwipeRefreshLayout, and it sends 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 itshelpView.

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 asStackView 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?