How to develop a Small App

Small Apps are miniature apps that run on top of other applications to enable true multi-tasking. With the Sony Add-on SDK you can create your own Small Apps easily using the code examples and documentation available.  This enables you to create innovative use cases and gain more visibility to your app through predefined searches from the UI on supported devices.

Small Apps provide an easy way to perform several tasks at the same time. For example, you could browse the web for information about specific restaurants in a Small App web browser, whilst simultaneously running Google Maps in the background to find restaurant locations. In general, a Small App can have almost the same functionality as a normal app, but it’s optimized to run on top of another user activity.

Supported devices
Small Apps are available in most Xperia devices running Android 4.1 or higher.

Get started developing your own Small App
To get started, we’ll go through the sample code project provided in the Sony Add-on SDK, called SmallAppSample.  The most important parts of the sample code are in the AndroidManifest.xml and in the MainApplication.java class. We’ll go through those in detail and explain the most important sections for you to keep a track of.

small apps sample

SmallAppSample, showing a Small App clock.

Step 1. Create a Small App class by extending SmallApplication class
To create the Small App component, you have to extend SmallApplication:

public class MainApplication extends SmallApplication {

This is the main class of the Small App, and it behaves a lot like an Activity, with onCreate(), onStart(), and onDestroy() methods just like those found in an Activity.

Step 2. Configure the Small App window
In onCreate(), set the layout, in the same way as with an Activity:

setContentView(R.layout.main);

It is also possible to set a layout for when the app is minimized.  This is optional, and if not called, the application icon is displayed instead:

setMinimizedView(R.layout.minimized);

The width and height of the Small App must however be set:

SmallAppWindow.Attributes attr = getWindow().getAttributes();

attr.width = getResources().getDimensionPixelSize(R.dimen.width);
attr.height = getResources().getDimensionPixelSize(R.dimen.height);

Control the appearance and behaviour of the Small App window using the minimum width and height attributes. You should also set these if your Small App is to show a title bar.

If setting the minimum size, make sure to set the smallest value possible that your app functions correctly with, on devices with small screens. The FLAG_RESIZABLE flag must be set as well.

attr.minWidth = getResources().getDimensionPixelSize(R.dimen.min_width);
attr.minHeight = getResources().getDimensionPixelSize(R.dimen.min_height);
attr.flags |= SmallAppWindow.Attributes.FLAG_RESIZABLE;

To learn more about the attributes you can use, see the API references about SmallAppWindow.Attributes.

Finally, set the window attributes:

getWindow().setAttributes(attr);

Step 3. Make additions to AndroidManifest.xml
To use the Small App API, you must declare the following permission in the AndroidManifest.xml::

<uses-permission android:name=”com.sony.smallapp.permission.SMALLAPP” />

You must also specify the use of the Small Apps shared library, which your application will compile against:

<uses-library android:name=”com.sony.smallapp.framework” />

Then you must declare the class containing your Small App implementation as a service, with the “exported” attribute being “true”:

<service android:name=“SampleSmallApp” android:exported=“true” >

The service must have the following intent-filter:

<service
    android:name="MainApplication"
    android:exported="true" >
    <intent-filter>
        <action android:name="com.sony.smallapp.intent.action.MAIN" />
        <category android:name="com.sony.smallapp.intent.category.LAUNCHER" />
    </intent-filter>
</service>

And that is almost it!  If you’ve tested your app and you’re ready to publish it, then add the description below on Google Play™ to enable Small App users find your app.

Make your Small App visible to end users
To make your Small App show up in the UI of a supported device (when end users search using the predefined Google Play query for Small App), the app description on Google Play must include the following text:

Small Apps s extension for Sony products

In addition, if the app is “only a Small App” in itself, we recommended you to add “Small App” or “small app” to the application title on Google Play. For example, “Clock Small App” or “Viewer Small App”. Please note that this relates to the title on Google Play, not for the APK name itself.

More information:

Comments 5

Sort by: Newest | Oldest | Most popular

  1. By Avdhu Singh

    #1

    In the Create New Project window, enter the following values:
    Application Name: “My First App”
    Company Domain: “example.com”
    You might want to change the project location. Also, if you want to write a Kotlin app, check the Include Kotlin support checkbox. Leave the other options as they are. https://babasupport.org/routers/zte-router-customer-service/657

    Click Next.
    1. In the Target Android Devices screen, keep the default values and click Next.
    2. In the Add an Activity to Mobile screen, select Empty Activity and click Next.
    3. In the Configure Activity screen, keep the default values and click Finish.

  2. By Michael Blackburn

    #2

    Nice to see Sony supporting their developers by answering questions.

    • By Tobias Nilsson

      #3

      Hi Michael,

      well spotted. This comment was unfortunately missed when it was first posted. We are very supportive of anyone developing for Sony products, so this is definitely something we will try to do better going forward. Also, we strongly encourage developers to post questions on http://stackoverflow.com/ and tag the question “Sony”. We actually have a team of developers that constantly monitor, contribute and reply to questions regarding our SDKs and APIs at Stack Overflow.

      Regards,
      Tobias from Developer World

  3. By just visiting

    #4

    I tired to run SmallAppSample (Smartwatch2) from eclipse. It works fine on emulator but when I try to deploy on device it fails with error:

    12-22 15:50:37.248: E/PackageManager(761): Package com.sony.nfx.app.smallappsample requires unavailable shared library com.sony.smallapp.framework; failing!

    I made sure in project properties, in “Java build path”, “Order and export” tab, “Sony add-on SDK 2.1” is selected.

    Any ideas how to include shared library/ fix the problem?

1-5 of 5 comments.