Skip to content

Instantly share code, notes, and snippets.

@varis
Created August 5, 2011 23:51
Show Gist options
  • Save varis/1128798 to your computer and use it in GitHub Desktop.
Save varis/1128798 to your computer and use it in GitHub Desktop.
Android / System Services
// AndroidManifest.xml must have the following permission:
// <uses-permission android:name="android.permission.GET_TASKS"/>
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
// AndroidManifest.xml must have the following permission:
// <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
try {
final Class<?> sysProp = Class.forName("android.os.SystemProperties");
final Method get = sysProp.getMethod("get", new Class<?>[]{String.class});
final String ret = (String) get.invoke(sysProp, new Object[]{"persist.sys.aabbcc"});
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// adb shell setprop / getprop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment