com.sony.smallapp
Class SmallApplication

java.lang.Object
  extended by android.content.ContextWrapper
      extended by com.sony.smallapp.SmallApplication

public class SmallApplication
extends android.content.ContextWrapper

SmallApplication class is the base class to implement each Small App. SmallApplication class has similar API and similar lifecycle with Activity. Each SmallApplication classes have SmallAppWindow to interact with the user and you can use #setContentView(int) to place your UI on SmallAppWIndow.

All SmallApplication classes must have a corresponding <service> declaration in their package's AndroidManifest.xml.

SmallApplication Lifecycle

The following diagram shows the important state paths of a SmallApplication.

State diagram for a SmallApplication Lifecycle.

All SmallApplication classes must have a corresponding <service> declaration in their package's AndroidManifest.xml.

Declaring the Small App in the manifest

You must declare your Small App in the manifest file in order for it to be accessible to the system. To declare your Small App, open your manifest file and add an <service> element as a child of the <application> element.
<service> element must have the attribute android:exported="true". In addition this, you must add <uses-permission> element and <uses-library> element to use Small Apps feature.

Here is an example:

     <manifest ...>
        ...
        <uses-permission android:name="com.sony.smallapp.permission.SMALLAPP" />
        ...
        <application ...>
            ...
            <uses-library android:name="com.sony.smallapp.framework" />
            ...
            <service 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>
        ...
     </manifest>
 

In <service> element, you must declare intent-filter like an example above. <action> element is mandatory but you can drop <category> element if your application should not be listed on Small Apps launcher.

Configuration Changes

If the configuration of the device (as defined by the Resources.Configuration class) changes, the Small App will restart because everything in the user interface will need to be updated to match this configuration. In order to handle the configuration change, you can override #onSmallAppConfigurationChanged(Configuration) method.


Constructor Summary
SmallApplication()
           
 
Method Summary
 android.view.View findViewById(int id)
          Finds a view that was identified by the ID attribute from the XML that was processed in onCreate().
 void finish()
          Call this when your Small App is done and should be closed.
 SmallAppWindow getWindow()
          Retrieve the current SmallAppWindow for the Small App.
protected  void onCreate()
          Called when the Small App is starting.
protected  void onDestroy()
          Perform any final cleanup before a Small App is destroyed.
protected  boolean onSmallAppConfigurationChanged(android.content.res.Configuration newConfig)
          Called when the device configuration changes while your Small App is running.
protected  void onStart()
          Called after onCreate().
protected  void onStop()
          Called when the Small App is no longer visible to the user.
 void setContentView(android.view.View view)
          Set the Small App content to an explicit view.
 void setMinimizedView(android.view.View view)
          Set the Small App content to show when the Small App is minimized.
 void setTitle(java.lang.CharSequence title)
          Change the title associated with this Small App.
 void setTitle(int titleResID)
          Change the title associated with this Small App.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmallApplication

public SmallApplication()
Method Detail

onCreate

protected void onCreate()
Called when the Small App is starting. This is where most initialization should go: calling #setContentView(int) to inflate the Small App's UI, using findViewById(int) to programmatically interact with widgets in the UI, etc.

Derived classes must call through to the super class's implementation of this method.


onDestroy

protected void onDestroy()
Perform any final cleanup before a Small App is destroyed.

Derived classes must call through to the super class's implementation of this method.


setContentView

public void setContentView(android.view.View view)
Set the Small App content to an explicit view. This view is placed directly into the Small App's view hierarchy. It can itself be a complex view hierarchy.

Parameters:
view - The desired content to display

setMinimizedView

public void setMinimizedView(android.view.View view)
Set the Small App content to show when the Small App is minimized. By default application icon is shown in minimized view.

Parameters:
view - The extra content to show when minimized.

findViewById

public android.view.View findViewById(int id)
Finds a view that was identified by the ID attribute from the XML that was processed in onCreate().

Parameters:
id - Resource ID for desired view.
Returns:
The view if found otherwise null.

setTitle

public void setTitle(java.lang.CharSequence title)
Change the title associated with this Small App.

Parameters:
title - Title.

setTitle

public void setTitle(int titleResID)
Change the title associated with this Small App.

Parameters:
titleResID - Resource ID for desired title.

onStop

protected void onStop()
Called when the Small App is no longer visible to the user. The counterpart to onStart().

Derived classes must call through to the super class's implementation of this method.


onStart

protected void onStart()
Called after onCreate(). The Small App is now being displayed to the user. The counterpart to onStop().

Derived classes must call through to the super class's implementation of this method.


getWindow

public SmallAppWindow getWindow()
Retrieve the current SmallAppWindow for the Small App.


onSmallAppConfigurationChanged

protected boolean onSmallAppConfigurationChanged(android.content.res.Configuration newConfig)
Called when the device configuration changes while your Small App is running. The returned boolean value determines whether or not the Small App will restart.

Parameters:
newConfig - The new device configuration.
Returns:
Return true if the the Small App should not restart. If false, the Small App will restart.
See Also:
android.app.Service#onConfigurationChanged(android.content.res.Configuration)

finish

public void finish()
Call this when your Small App is done and should be closed.