Getting Started
This document describes
how to develop and run an AllShare application with AllShare Framework. Topics covered include: installing the AllShare Framework Development Tool and the AllShare Framework SDK, creating an AllShare application with sample code, and running the application with AllShare Simulators. From this document, you can learn the basic steps of developing AllShare Applications.
1. AllShare Framework Development Tool and SDK Installation
To develop an AllShare application, the AllShare Framework Development Tool and the AllShare Framework SDK is required. The AllShare Framework Development Tool is an Eclipse plugin that enables developers to create AllShare applications on the Android platform. It provides download and update manager of the AllShare Framework SDK, the AllShare application wizard, and the AllShare Simulators. The AllShare Framework SDK consists of the AllShare Library, API documents, sample codes, and AllShare Framework Service Packages for the emulator. For more information about AllShare Framework Development Tool and AllShare Framework SDK, refer to the document: “AllShare Framework Developer’s Guide: Testing Guide.”
Eclipse update site :
http://developer.samsung.com/allshare/repository/android/latest/tool
URL copied to clipboard.
To install the AllShare Framework SDK and Tools,
open Eclipse, goto 'Help > Install New Software',
and paste this URL into the dialog box.
-
1.1. Setting up the Environment
HideBefore installing the AllShare Framework Development Tool, you should prepare the Android development environment within Eclipse IDE. This section provides instructions on how to set up this environment. If you are already available to develop an Android application with Eclipse IDE, you can skip this section and go to Section 1.2.
- Checking the development system
The AllShare Framework Development Tool supports Windows 7, Ubuntu 10.10 or higher with GStreamer installed and Mac OS X 10.7 or higher with QuickTime Player 10.1 or higher installed as a development system.
- Installing the Java Development Kit
Download and install JDK specific for your operating system. The instructions are available on the JDK web site.
- Microsoft Windows: http://docs.oracle.com/javase/7/docs/webnotes/install/index.html#windows
- Linux distributions: http://docs.oracle.com/javase/7/docs/webnotes/install/#linux
- Mac OS X: http://docs.oracle.com/javase/7/docs/webnotes/install/#mac
By using these JDKs you are sure to have all libraries necessary for operation of AllShare Framework Development Tool.
Some OS distributions may contain “headless” distributions, that do not include graphical libraries (an example is openjdk-6-jre-headless in Ubuntu).
While AllShare Framework Development Tool tries to handle this situation by informing user, it is better to make sure you are not using one of those. - Installing the Eclipse IDE
Download the Eclipse IDE 3.7 Indigo or later version available on Eclipse Downloads page below.
The "Eclipse Classic" version is recommended.http://www.eclipse.org/downloads/
- Unzip the downloaded file to a target folder.
- Run Eclipse IDE by launching "eclipse" application located in the main folder.
- Installing Android SDK
Follow the instructions on the web site below. The required Android platform version is 4.1 or higher.
- Installing ADT Plugin for Eclipse
Follow the instructions on the web site below.
https://developer.android.com/sdk/eclipse-adt.html#installing
The required ADT version is 20.0 or higher. And if a later version of ADT requires the update of AllShare Framework SDK, it will be notified at AllShare Developer’s site.
- Setting Web Browser to be used by TV Web Browser simulator
To use TV Web Browser simulator provided by AllShare Framework Development Tool, it is necessary for Eclipse to use default internal web browser.
This can be done by opening preferences window (Window -> Preferences), opening Web Browser configuration tab (General -> Web Browser), and selecting “Use internal web browser”.
On Linux machines, the internal browser may not be configured. It is advised to run
sudo apt-get install libwebkitgtk-1.0-0 - Installing GStreamer for Linux
Download and install GStreamer using your distribution install manager.
For example, on Ubuntu:
- 1) Open Terminal (by selecting Applications -> Accessories -> Terminal)
- 2) Gain root access by typing in “sudo su” and entering root password
- 3) Install required GStreamer packages by entering command
sudo apt-get install gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mp3 gstreamer0.10-gnonlin gstreamer0.10-sdl gstreamer0.10-plugins-bad-multiverse gstreamer0.10-plugins-bad gstreamer0.10-plugins-ugly totem-plugins-extra gstreamer-dbus-media-service gstreamer-tools ubuntu-restricted-extras ttf-mscorefonts-installer
- 4) Agree to any package installation by pressing “Y” if asked.
- Installing QuickTime Player for Mac OS X
The official QuickTime for Mac OS X can be found on a web site below.
- Checking the development system
-
1.2. Installing AllShare Framework Development Tool and SDK
HideAssuming that you have installed the Eclipse IDE and the ADT, as described above, this section explains how to install the AllShare Framework Development Tool and AllShare Framework SDK. You can install the AllShare Framework Development Tool as a plugin of Eclipse IDE from the install menu of the Eclipse, and install the AllShare Framework SDK from the update menu of the AllShare Framework Development Tool.
1. Start Eclipse, then select Help > Install New Software.

2. Click Add in the top right corner. In the Add Repository window that appears, enter AllShare Framework Development Tool for the Name and the following URL for the Location. Then, click OK.
Eclipse update site :
http://developer.samsung.com/allshare/repository/android/latest/tool
URL copied to clipboard. To install the AllShare Framework SDK and Tools,
open Eclipse, goto 'Help > Install New Software',
and paste this URL into the dialog box.
3. In the Available Software dialog, select the checkbox of AllShare Development Tool and click Next.

4. Review installation details, then click Next.

5. Read and accept license agreements, then click Finish.

6. You can see the downloading status and tools from the window.

Note If you get a security warning about the authenticity or validity of the software during the installation process as below, click OK.

7. When installation completes, click Restart Now to restart Eclipse.

Installation of the AllShare Framework Development Tool will invoke restart of the Eclipse IDE. When restarted, the Eclipse shows the AllShare Framework SDK Setup dialog. The following instructions help you in configuring the AllShare Framework SDK.
8. Select a location to store AllShare Framework SDK.
This repository will contain project samples, libraries, and other items necessary in the development process.
9. In the AllShare Framework SDK Manager window that appears, check the update lists, then click Install selected components.

10. After finishing the SDK update, click OK.
The AllShare Framework Development Tool installation is completed.
2. Application Development At a Glance
This section describes creating, writing and running an AllShare application that performs device discovery. With the given sample project code, you can develop your first AllShare application in short time.
-
2.1. Creating a new AllShare project
Hide1. Strart Eclipse, and select File > New > AllShare Android Project

2. Enter DeviceDiscovery for the Project Name and select Create new project in workspace, then click Next.

3. Select which AllShare Framework version should be used by the project, then click Next

4. Select Android Build Target (version of Android API that will be used by project), then click Next.
In the following picture, Android 4.1.2 is chosen.NoteThe AllShare Framework SDK requires Android platform 4.1 or higher

5. Enter DeviceDiscovery for the Application Name, com.sec.android.allshare.devicediscovery for the Package Name and Main for the Create Actvity field of dialog. Then, click Finish.

A new AllShare project is visible in the Package Explorer view.

-
2.2. Writing an AllShare application
HideNow, you can write and modify the skeleton code of the AllShare application, so as to discover other AllShare devices in the local network. Follow the instructions below.
- Get Android permissions
Before using AllShare Framework APIs, “Uses Permission” should be added to “AndroidManifest.xml”. If the project is created as an AllShare Project, “com.sec.android.permission.PERSONAL_MEDIA” permission is already included. Otherwise, you should add the following permission in “AndroidManifest.xml”.
<AndroidManifest.xml>
…… </application> <uses-permission android:name="com.sec.android.permission.PERSONAL_MEDIA" /> </manifest> - Modify the XML layout
To launch the AllShare application, the following code should be added in “main.xml” as below.
<main.xml>
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/txtLog" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="==AllShare Device Discovery==" /> </LinearLayout> - Connect to the AllShare Framework Service
Because the AllShare Framework is running as a service, AllShare applications should connect to this service before using AllShare Framework APIs. When connected, a ServiceProvider instance is created. With this instance an AllShare application can discover and control other AllShare devices in the local network. To this end, add the following code in “Main.java” as below
NoteThe modified source files are available here . (DeviceDiscovery.zip)
<Main.java>
public class Main extends Activity { /** Called when the activity is first created. */ ServiceProvider mServiceProvider = null; TextView mText = null; Handler mHandler = new Handler(); /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mText = (TextView) findViewById(R.id.txtLog); mText.append("\n\n" + "Creating service provider!" + "\r\n\n"); ERROR err = ServiceConnector.createServiceProvider(this, new IServiceConnectEventListener() { @Override public void onCreated(ServiceProvider sprovider, ServiceState state) { mServiceProvider = sprovider; showDeviceList(); } @Override public void onDeleted(ServiceProvider sprovider) { mServiceProvider = null; } }); if (err == ERROR.FRAMEWORK_NOT_INSTALLED) { // AllShare Framework Service is not installed. } else if (err == ERROR.INVALID_ARGUMENT) { // Input argument is invalid. Check and try again } else { // Success on calling the function. } }If createServiceProvider() succeeds IServiceConnectEventListener, onCreated() will be called with a ServiceProvider instance.
- Discover network devices
To discover AllShare devices in the local network, the application should get a DeviceFinder instance by calling getDeviceFinder(). In the AllShare Framework, an AllShare device in the local network is represented as an instance of Device class, and there are several device types which have different functionalities: Media Provider, AV Player, Image Viewer, and TV Browser.
<Main.java>
private void showDeviceList() { if (mServiceProvider == null) return; DeviceFinder mDeviceFinder = mServiceProvider.getDeviceFinder(); mDeviceFinder.setDeviceFinderEventListener(DeviceType.DEVICE_AVPLAYER, mDeviceDiscoveryListener); ArrayList<Device> mDeviceList = mDeviceFinder.getDevices(DeviceDomain.LOCAL_NETWORK, DeviceType.DEVICE_AVPLAYER); if (mDeviceList != null) { for (int i = 0; i < mDeviceList.size(); i++) { mText.append("AVPlayer: " + mDeviceList.get(i).getName() + " [" + mDeviceList.get(i).getIPAdress() + "] is found" + "\r\n"); } } }In order to get events such as join and leave of AllShare devices, the application should register setDeviceFinderEventListener with a device type of interest and a listener instance. The listener instance can be made by implementing the interface as below.
<Main.java>
private final DeviceFinder.IDeviceFinderEventListener mDeviceDiscoveryListener = new IDeviceFinderEventListener() { @Override public void onDeviceRemoved(DeviceType deviceType, Device device, ERROR err) { mText.append("AVPlayer: " + device.getName() + " [" + device.getIPAdress() + "] is removed" + "\r\n"); } @Override public void onDeviceAdded(DeviceType deviceType, Device device, ERROR err) { mText.append("AVPlayer: " + device.getName() + " [" + device.getIPAdress() + "] is found" + "\r\n"); } }; - Disconnect from the AllShare Framework Service
<Main.java>
@Override protected void onDestroy() { if (mServiceProvider != null) ServiceConnector.deleteServiceProvider(mServiceProvider); super.onDestroy(); }
- Get Android permissions
-
2.3. Running an AllShare application
Hide- Launching the AV Player Simulator
For simplicity, we search the AV Player Simulator instead of a smart device. This AllShare Simulator is already installed in the Eclipse IDE during the installation of the AllShare Framework SDK in Section 1.2.
To activate a simulator, follow the instructions below.1. Open the AllShare Simulator perspective from Window < Open Perspective < Simulator.

2. Click Activate in Simulator Manager view

3. Select AV Player and click OK.
NoteThe AllShare application in this document requires the AV Player Simulator.

Then, the AV Player Simulator appears in the Simulator View in Eclipse.

- Running the AllShare application
To launch the AllShare application, connect your smart phone to the development system, and follow the instructions below.
NoteCheck that the Android version of the phone is 4.1 or higher.
Run the AllShare application on the target device.
With project selected in Package Explorer, select Run > Run as > AllShare Application from top bar menu.
The application is built, installed, and launched automatically on the connected smart phone. Your application discovers the AV Player Simulator as below.

- Launching the AV Player Simulator


