You are on page 1of 16

Document Version

4.00
Date
Sony Corporation 2012-9-7

Development guideline of

SDK Add-on for Sony's tablet device

SmallApps API References


Document Version

4.00
Date
Sony Corporation 2012-9-7

Table of Contents
1 Package .............................................................................................................................................. 3
1.1 com.sony.smallapp ...................................................................................................................... 3
2 Interfaces............................................................................................................................................ 4
2.1 com.sony.smallapp.SmallAppWindow.OnWindowFocusChangeListener ................................. 4
2.2 com.sony.smallapp.SmallAppWindow.OnWindowStateChangeListener .................................. 4
3 Classes ................................................................................................................................................ 5
3.1 com.sony.smallapp.SdkInfo......................................................................................................... 5
3.2 com.sony.smallapp.SdkInfo.VERSION ....................................................................................... 5
3.3 com.sony.smallapp.SmallApplication ......................................................................................... 6
3.4 com.sony.smallapp.SmallAppWindow ...................................................................................... 11
3.5 com.sony.smallapp.SmallAppWindow.Attributes .................................................................... 13
4 Enums .............................................................................................................................................. 15
4.1 com.sony.smallapp.SmallAppWindow.WindowState ............................................................... 15

2/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

1 Package

1.1 com.sony.smallapp

Interfaces
SmallAppWindow.OnWindowFoc Interface definition for a callback to be invoked when the focus of a
usChangeListener window is changed.
SmallAppWindow.OnWindowStat Interface definition for a callback to be invoked when the state of a
eChangeListener window is changed.

Classes
SdkInfo Information about the SDK.
SdkInfo.VERSION Various version strings.
SmallApplication SmallApplication class is the base class to implement each small apps.
SmallAppWindow SmallAppWindow represents the window which renders the small app
content.
SmallAppWindow.Attributes Attributes of a window.

Enums
SmallAppWindow.WindowState A state of a window.

3/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

2 Interfaces

2.1 com.sony.smallapp.SmallAppWindow.OnWindowFocusChangeListener
public static interface SmallAppWindow.OnWindowFocusChangeListener

Class Overview
Interface definition for a callback to be invoked when the window focus is changed.

Summary
Public Methods
abstract void onWindowFocusChanged(boolean hasFocus)
Called when a window has got or lost the focus.

Public Methods
public abstract void onWindowFocusChanged(boolean hasFocus)
Called when a window has got or lost the focus.

2.2 com.sony.smallapp.SmallAppWindow.OnWindowStateChangeListener
public static interface SmallAppWindow.OnWindowStateChangeListener

Class Overview
Interface definition for a callback to be invoked when the window state is changed.

Summary
Public Methods
abstract void onWindowStateChanged(SmallAppWindow.WindowState state)
Called when the state of a window has been changed.

Public Methods
public abstract void onWindowStateChanged(SmallAppWindow.WindowState state)
Called when the state of a window has been changed.

4/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

3 Classes

3.1 com.sony.smallapp.SdkInfo
public class SdkInfo extends Object

Class Overview
Information about the SDK. It can obtain several information e.g. the version infomation,that the
small app is running, with this class.

Summary
Nested Classes
class SdkInfo.VERSION Various version strings.

Inherited Methods
From class java.lang.Object

3.2 com.sony.smallapp.SdkInfo.VERSION
public static class SdkInfo.VERSION extends Object

Class Overview
Various version strings.

Summary
Fields
public static final int API_LEVEL The user-visible API level of the small apps framework.

Inherited Methods
From class java.lang.Object

Fields
public static final int API_LEVEL
The user-visible API level of the small apps framework.

5/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

3.3 com.sony.smallapp.SmallApplication
public class SmallApplication extends ContextWrapper

Class Overview
SmallApplication class is the base class to implement each small apps. 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.

Small app is launched


Small app started
onCreate()
Small app is visible
onStart()

Small app is visible Small app is running


Small app is no longer visible
onStop()
Small app is finishing or being destroyed by the system
onDestroy()

Small app shut down

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.

6/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

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, then an
small app will be restarted because anything displaying a user interface will need to update to match
that configuration. In order to handle the configuration change, you can override
onSmallAppConfigurationChanged(Configuration) method.

Summary
Inherited Constants
From class android.content.Context

Public Constructors
SmallApplication()

Public Methods
View findViewById(int id)

7/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

Find 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.
void setContentView(int layoutResID)
Set the small app content from a layout resource.
void setContentView(View view)
Set the small app content to an explicit view.
void setMinimizedView(int layoutResID)
Set the small app content to show when the small app is minimized from a layout
resource.
void setMinimizedView(View view)
Set the small app content to show when the small app is minimized.
void setTitle(CharSequence title)
Change the title associated with this small app.
void setTitle(int titleResID)
Change the title associated with this small app.

Protected Methods
void onCreate()
Called when the small app is starting.
void onDestroy()
Perform any final cleanup before a small app is destroyed.
boolean onSmallAppConfigurationChanged(Configuration newConfig)
Called when the device configuration changes while your small app is running.
void onStart()
Called after onCreate().
void onStop()
Called when you are no longer visible to the user.

Inherited Methods
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object

8/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

Public Constructors
public SmallApplication()

Public Methods
public View findViewById(int id)
Find 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.

public void finish()


Call this when your small app is done and should be closed.

public SmallAppWindow getWindow()


Retrieve the current SmallAppWindow for the small app.

public void setContentView(int layoutResID)


Set the small app content from a layout resource. The resource will be inflated, adding all top-level
views to the small application.
Parameters
layoutResID Resource ID to be inflated.

public void setContentView(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

public void setMinimizedView(int layoutResID)


Set the small app content to show when the small app is minimized from a layout resource. By default
application icon is show in minimized view.
Parameters
layoutResID The layout id of the extra content

public void setMinimizedView(View view)


Set the small app content to show when the small app is minimized. By default application icon is
shown in minimized view.
9/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

Parameters
view The extra content to show when minimized.

public void setTitle(CharSequence title)


Change the title associated with this small app.
Parameters
title Title.

public void setTitle(int titleResID)


Change the title associated with this small app.
Parameters
titleResID Resource ID for desired title.

Protected Methods
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.

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.

protected boolean onSmallAppConfigurationChanged(Configuration newConfig)


Called when the device configuration changes while your small app is running. The returned boolean
value determines whether the small app will restart or not.
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
onConfigurationChanged(android.content.res.Configuration)

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.

10/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

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.

3.4 com.sony.smallapp.SmallAppWindow

public class SmallAppWindow extends Object

Class Overview
SmallAppWindow represents the window which renders the small app content. It provides UI
components such as a background, title area, drag handler, resize handler, close button, etc.
The SmallAppWindow instance is created automatically for the small app, and you can access the
SmallAppWindow instance associated to your small app using getWindow().

Summary
Nested Classes
class SmallAppWindow.Attributes Attributes of a window.
interface SmallAppWindow.OnWindo Interface definition for a callback to be invoked when the
wFocusChangeListener focus of a window is changed.
interface SmallAppWindow.OnWindo Interface definition for a callback to be invoked when the state
wStateChangeListener of a window is changed.
enum SmallAppWindow.WindowS A state of a window.
tate

Public Methods
final getAttributes()
SmallAppWindow.Attributes Retrieve attributes for this window.
final getWindowState()
SmallAppWindow.WindowS Get a current window state.
tate
void setAttributes(SmallAppWindow.Attributes attr)
Set attributes to this window.
void setBackgroundDrawable(Drawable drawable)
Change the background of this window to a custom Drawable.
void setHeaderView(View view)
Set the view such as option menus to header area.
void setOnWindowFocusChangeListener(SmallAppWindow.OnWindowFocusC

11/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

hangeListener l)
Register a callback to be invoked when the focus of a window is
changed.
void setOnWindowStateChangeListener(SmallAppWindow.OnWindowStateCh
angeListener l)
Register a callback to be invoked when the state of a window is
changed.
void setSoftInputMode(int mode)
Apply the soft input mode, as per
android.view.WindowManager.LayoutParams.softInputMode.
void setWindowState(SmallAppWindow.WindowState state)
Change a window state.

Inherited Methods
From class java.lang.Object

Public Methods
public final SmallAppWindow.Attributes getAttributes()
Retrieve attributes for this window.
Returns
Attributes for this window.

public final SmallAppWindow.WindowState getWindowState()


Get a current window state.
Returns
Current window state

public void setAttributes(SmallAppWindow.Attributes attr)


Set attributes to this window.
Parameters
attr Attributes.

public void setBackgroundDrawable(Drawable drawable)


Change the background of this window to a custom Drawable. The padding value of the Drawable is
used to determine where the content view specified by {link setContentView(int) should be placed.
Parameters
drawable The new window background or null to remove the background.

12/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

public void setHeaderView(View view)


Set the view such as option menus to header area.
Parameters
view The desired view.

public void setOnWindowFocusChangeListener(SmallAppWindow.OnWindowFocusChangeListener l)


Register a callback to be invoked when the focus of a window is changed.
Parameters
l The callback that will run

public void setOnWindowStateChangeListener(SmallAppWindow.OnWindowStateChangeListener l)


Register a callback to be invoked when the state of a window is changed.
Parameters
l The callback that will run

public void setSoftInputMode(int mode)


Apply the soft input mode, as per android.view.WindowManager.LayoutParams.softInputMode.
Parameters
mode Mode specifying soft input mode for this window, as per
android.view.WindowManager.LayoutParams.softInputMode.

public void setWindowState(SmallAppWindow.WindowState state)


Change a window state.
Parameters
state A state to be set

3.5 com.sony.smallapp.SmallAppWindow.Attributes

public static class SmallAppWindow.Attributes extends Object

Class Overview
Attributes of a window.

Summary
Constants
int FLAG_HARDWARE_AC Indicates whether this window should be hardware accelerated.
CELERATED
int FLAG_NO_TITLEBAR Flag for the "no titlebar" feature, turning off the title bar at the top of
13/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

window.
int FLAG_RESIZABLE Flag for the "resizable" feature.

Fields
public int flags Various behavioral options/flags.
public int height Information about the desired height of this window.
public int maxHeight Information about the desired maximum height of this window.
public int maxWidth Information about the desired maximum width of this window.
public int minHeight Information about the desired minimum height of this window.
public int minWidth Information about the desired minimum width of this window.
public int width Information about the desired width of this window.

Public Constructors
SmallAppWindow.Attributes()

Inherited Methods
From class java.lang.Object

Constants
public static final int FLAG_HARDWARE_ACCELERATED
Indicate whether this window should be hardware accelerated.
Constant Value : 4 (0x00000004)

public static final int FLAG_NO_TITLEBAR


Flag for the "no titlebar" feature. Turn off the title bar at the top of window.
When the window has a titlebar, the application content area is reduced to the area below the titlebar.
When the titlebar is turned off, the content area is filling the whole window (except that background
image padding).
Constant Value : 1 (0x00000001)

public static final int FLAG_RESIZABLE


Flag for the "resizable" feature. This is enabled by default.
Constant Value : 2 (0x00000002)

Fields
public int flags
Various behavioral options/flags.

14/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

See Also
FLAG_NO_TITLEBAR
FLAG_RESIZABLE
FLAG_HARDWARE_ACCELERATED

public int height


Information about the desired height of this window.

public int maxHeight


Information about the desired maximum height of this window.

public int maxWidth


Information about the desired maximum width of this window.

public int minHeight


Information about the desired minimum height of this window.

public int minWidth


Information about the desired minimum width of this window.

public int width


Information about the desired width of this window.

Public Constructors
public SmallAppWindow.Attributes()

4 Enums

4.1 com.sony.smallapp.SmallAppWindow.WindowState
public static final enum SmallAppWindow.WindowState extends Enum<E extends Enum<E>>

Class Overview
A state of a window.

15/16
Copyright 2012 Sony Corporation
Document Version

4.00
Date
Sony Corporation 2012-9-7

Summary
Enum Values
SmallAppWindow. FITTED The window is fitted to a screen.
WindowState
SmallAppWindow. MINIMIZED A window is minimized and positioned to the edge of screen.
WindowState
SmallAppWindow. NORMAL General state of a window.
WindowState

Public Methods
static SmallAppWindow.WindowState valueOf(String name)
final static WindowState[] values()

Inherited Methods
From class java.lang.Enum
From class java.lang.Object
From interface java.lang.Comparable

Enum Values
public static final SmallAppWindow.WindowState FITTED
The window is fitted to a screen.

public static final SmallAppWindow.WindowState MINIMIZED


A window is minimized and positioned to the edge of screen.

public static final SmallAppWindow.WindowState NORMAL


General state of a window.

Public Methods
public static SmallAppWindow.WindowState valueOf(String name)

public static final WindowState[] values()

16/16
Copyright 2012 Sony Corporation

You might also like