Professional Documents
Culture Documents
4.00
Date
Sony Corporation 2012-9-7
Development guideline of
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.
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.
4.00
Date
Sony Corporation 2012-9-7
Parameters
view The extra content to show when minimized.
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.
10/16
Copyright 2012 Sony Corporation
Document Version
4.00
Date
Sony Corporation 2012-9-7
3.4 com.sony.smallapp.SmallAppWindow
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.
12/16
Copyright 2012 Sony Corporation
Document Version
4.00
Date
Sony Corporation 2012-9-7
3.5 com.sony.smallapp.SmallAppWindow.Attributes
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)
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 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 Methods
public static SmallAppWindow.WindowState valueOf(String name)
16/16
Copyright 2012 Sony Corporation