public class DownloaderClientMarshaller extends Object
The IPC is implemented using an Android Messenger and a service Binder. The connect method should be called whenever the client wants to bind to the service. It opens up a service connection that ends up calling the onServiceConnected client API that passes the service messenger in. If the client wants to be notified by the service, it is responsible for then passing its messenger to the service in a separate call.
Critical methods are startDownloadServiceIfRequired(android.content.Context, android.app.PendingIntent, java.lang.Class<?>) and CreateStub(com.google.android.vending.expansion.downloader.IDownloaderClient, java.lang.Class<?>).
When your application first starts, you should first check whether your app's expansion files are
already on the device. If not, you should then call startDownloadServiceIfRequired(android.content.Context, android.app.PendingIntent, java.lang.Class<?>), which
starts your DownloaderService to download the expansion files if necessary. The method
returns a value indicating whether download is required or not.
If a download is required, startDownloadServiceIfRequired(android.content.Context, android.app.PendingIntent, java.lang.Class<?>) begins the download through
the specified service and you should then call CreateStub(com.google.android.vending.expansion.downloader.IDownloaderClient, java.lang.Class<?>) to instantiate a member IStub object that you need in order to receive calls through your IDownloaderClient
interface.
| Modifier and Type | Field and Description |
|---|---|
static int |
DOWNLOAD_REQUIRED |
static int |
LVL_CHECK_REQUIRED |
static int |
MSG_ONDOWNLOADPROGRESS |
static int |
MSG_ONDOWNLOADSTATE_CHANGED |
static int |
MSG_ONSERVICECONNECTED |
static int |
NO_DOWNLOAD_REQUIRED |
static String |
PARAM_MESSENGER |
static String |
PARAM_NEW_STATE |
static String |
PARAM_PROGRESS |
| Constructor and Description |
|---|
DownloaderClientMarshaller() |
| Modifier and Type | Method and Description |
|---|---|
static IDownloaderClient |
CreateProxy(android.os.Messenger msg)
Returns a proxy that will marshal calls to IDownloaderClient methods
|
static IStub |
CreateStub(IDownloaderClient itf,
Class<?> downloaderService)
Returns a stub object that, when connected, will listen for marshaled
IDownloaderClient methods and translate them into calls to the supplied
interface. |
static int |
startDownloadServiceIfRequired(android.content.Context context,
android.content.Intent notificationClient,
Class<?> serviceClass)
This version assumes that the intent contains the pending intent as a parameter.
|
static int |
startDownloadServiceIfRequired(android.content.Context context,
android.app.PendingIntent notificationClient,
Class<?> serviceClass)
Starts the download if necessary.
|
public static final int MSG_ONDOWNLOADSTATE_CHANGED
public static final int MSG_ONDOWNLOADPROGRESS
public static final int MSG_ONSERVICECONNECTED
public static final String PARAM_NEW_STATE
public static final String PARAM_PROGRESS
public static final String PARAM_MESSENGER
public static final int NO_DOWNLOAD_REQUIRED
public static final int LVL_CHECK_REQUIRED
public static final int DOWNLOAD_REQUIRED
public static IDownloaderClient CreateProxy(android.os.Messenger msg)
msg - public static IStub CreateStub(IDownloaderClient itf, Class<?> downloaderService)
IDownloaderClient methods and translate them into calls to the supplied
interface.itf - An implementation of IDownloaderClient that will be called
when remote method calls are unmarshaled.downloaderService - The class for your implementation of DownloaderService.IStub that allows you to connect to the service such that
your IDownloaderClient receives status updates.public static int startDownloadServiceIfRequired(android.content.Context context,
android.app.PendingIntent notificationClient,
Class<?> serviceClass)
throws android.content.pm.PackageManager.NameNotFoundException
context - Your application Context.notificationClient - A PendingIntent to start the Activity in your application
that shows the download progress and which will also start the application when download
completes.serviceClass - the class of your imp.DownloaderService implementationNO_DOWNLOAD_REQUIRED, LVL_CHECK_REQUIRED, or DOWNLOAD_REQUIRED.android.content.pm.PackageManager.NameNotFoundExceptionpublic static int startDownloadServiceIfRequired(android.content.Context context,
android.content.Intent notificationClient,
Class<?> serviceClass)
throws android.content.pm.PackageManager.NameNotFoundException
The pending intent must be in an extra with the key DownloaderService.EXTRA_PENDING_INTENT.
context - notificationClient - serviceClass - the class of the service to startandroid.content.pm.PackageManager.NameNotFoundExceptionCopyright © 2012–2014 simpligility technologies inc.. All rights reserved.