Show me the code! – By Davanum Srinivas

December 14, 2007

Android – Accessing the system services

Filed under: Uncategorized — Davanum Srinivas @ 9:59 am

Here’s a partial listing of the available services on android.

Access the Service Manager and list available services

android.os.IServiceManager sm = android.os.ServiceManagerNative.getDefault();
        try {
            String[] services = sm.listServices();
            for (int i = 0; i < services.length; i++) {
                Log.i("Services", i + " : " + services[i]);
            }
        } catch (DeadObjectException e) {
            Log.i("Services", e.getMessage(), e);
        }

Now we try to dig thru the API to figure out which ones are available to applications. Here’s what i have found so far.

USB

android.os.IUsb usbService = android.os.IUsb.Stub.asInterface(sm.getService("USB"));

javadoc – IUsb

activity

android.app.IActivityManager activityService = android.app.IActivityManager.Stub.asInterface(sm.getService("activity"));

alarm

android.app.IAlarmManager alarmService = android.app.IAlarmManager.Stub.asInterface(sm.getService("alarm"));

content

android.content.IContentService contentService = android.content.IContentService.Stub.asInterface(sm.getService("content"));

location

android.location.ILocationManager locationService = android.location.ILocationManager.Stub.asInterface(sm.getService("location"));

notification

android.app.INotificationManager notificationService = android.app.INotificationManager.Stub.asInterface(sm.getService("notification"));

org.bluez.bluetooth

	org.bluez.IBluetoothService bluetoothService = org.bluez.IBluetoothService.Stub.asInterface(sm.getService("org.bluez.bluetooth_service"));

javadoc – IBluetoothService

package

android.content.IPackageManager packageService = android.content.IPackageManager.Stub.asInterface(sm.getService("package"));

phone

android.telephony.IPhone phoneService = android.telephony.IPhone.Stub.asInterface(sm.getService("phone"));

javadoc – IPhone

power

android.os.IPowerManager powerService = android.os.IPowerManager.Stub.asInterface(sm.getService("power"));

statistics

android.os.IStatisticsService statisticsService = android.os.IStatisticsService.Stub.asInterface(sm.getService("statistics"));

statusbar

android.server.status.IStatusBar statusbarService = android.server.status.IStatusBar.Stub.asInterface(sm.getService("statusbar"));

vibrator

android.os.IVibratorService vibratorService = android.os.IVibratorService.Stub.asInterface(ServiceManager.getService("vibrator"));

volume

android.view.IRingerVolume volumeService = android.view.RingerVolumeNative.asInterface(sm.getService("volume"));

window

android.view.IWindowManager windowService = android.view.IWindowManager.Stub.asInterface(sm.getService("window"));

3 Comments »

  1. Hey can u explain me ,what are the return types of all classes and interface use for IPC in android.
    For instance, IBinder,parcel,bluetooth..

    Comment by sony — July 19, 2010 @ 5:50 am

  2. Hey,

    I keep getting the error: android.app.INotificationManager cannot be resolved to a type

    any idea’s?

    Comment by Blundell — September 30, 2010 @ 5:53 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: