android Programming Glossary: getsystemservice
Close/hide the Android Soft Keyboard http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard your edit field. InputMethodManager imm InputMethodManager getSystemService Context.INPUT_METHOD_SERVICE imm.hideSoftInputFromWindow myEditText.getWindowToken..
Android: Binding data from a database to a CheckBox in a ListView? http://stackoverflow.com/questions/1505751/android-binding-data-from-a-database-to-a-checkbox-in-a-listview cur ViewGroup parent LayoutInflater li LayoutInflater getSystemService Context.LAYOUT_INFLATER_SERVICE return li.inflate R.layout.mylist..
How to check internet access on Android? InetAddress never timeouts http://stackoverflow.com/questions/1560788/how-to-check-internet-access-on-android-inetaddress-never-timeouts isOnline ConnectivityManager cm ConnectivityManager getSystemService Context.CONNECTIVITY_SERVICE NetworkInfo netInfo cm.getActiveNetworkInfo..
Android: I want to shake it http://stackoverflow.com/questions/2317428/android-i-want-to-shake-it method do this in onCreate mSensorManager SensorManager getSystemService Context.SENSOR_SERVICE mSensorManager.registerListener mSensorListener..
How to find serial number of Android device? http://stackoverflow.com/questions/2322234/how-to-find-serial-number-of-android-device TelephonyManager tManager TelephonyManager myActivity.getSystemService Context.TELEPHONY_SERVICE String uid tManager.getDeviceId getSystemService.. Context.TELEPHONY_SERVICE String uid tManager.getDeviceId getSystemService is a method from the Activity class. getDeviceID will return..
Detect application heap size in Android http://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android be invoked as follows ActivityManager am ActivityManager getSystemService ACTIVITY_SERVICE int memoryClass am.getMemoryClass Log.v onCreate..
Download a file with Android, and showing the progress in a ProgressDialog http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog during download PowerManager pm PowerManager context.getSystemService Context.POWER_SERVICE PowerManager.WakeLock wl pm.newWakeLock.. and enqueue file DownloadManager manager DownloadManager getSystemService Context.DOWNLOAD_SERVICE manager.enqueue request Download progress..
Programmatically switching off Android phone http://stackoverflow.com/questions/3745523/programmatically-switching-off-android-phone for me. KeyguardManager keyguardManager KeyguardManager getSystemService Activity.KEYGUARD_SERVICE KeyguardLock lock keyguardManager.newKeyguardLock..
Android - Camera preview is sideways http://stackoverflow.com/questions/3841122/android-camera-preview-is-sideways mCamera.getParameters Display display WindowManager getSystemService WINDOW_SERVICE .getDefaultDisplay if display.getRotation Surface.ROTATION_0..
Android - detect whether there is an Internet connection available [duplicate] http://stackoverflow.com/questions/4238921/android-detect-whether-there-is-an-internet-connection-available connectivityManager ConnectivityManager getSystemService Context.CONNECTIVITY_SERVICE NetworkInfo activeNetworkInfo connectivityManager.getActiveNetworkInfo..
Example: Communication between Activity and Service using Messaging http://stackoverflow.com/questions/4300291/example-communication-between-activity-and-service-using-messaging true private void showNotification nm NotificationManager getSystemService NOTIFICATION_SERVICE In this sample we'll use the same text..
How to programatically create and read WEP/EAP WiFi configurations in Android? http://stackoverflow.com/questions/4374862/how-to-programatically-create-and-read-wep-eap-wifi-configurations-in-android code void saveWepConfig WifiManager wifi WifiManager getSystemService Context.WIFI_SERVICE WifiConfiguration wc new WifiConfiguration.. wc.wepTxKeyIndex 0 WifiManager wifiManag WifiManager this.getSystemService WIFI_SERVICE boolean res1 wifiManag.setWifiEnabled true int.. code void readWepConfig WifiManager wifi WifiManager getSystemService Context.WIFI_SERVICE List WifiConfiguration item wifi.getConfiguredNetworks..
creating a system overlay (always on top) button in android http://stackoverflow.com/questions/4481226/creating-a-system-overlay-always-on-top-button-in-android Load Average WindowManager wm WindowManager getSystemService WINDOW_SERVICE wm.addView mView params @Override public void.. Toast.LENGTH_LONG .show if mView null WindowManager getSystemService WINDOW_SERVICE .removeView mView mView null class HUDView extends.. Load Average WindowManager wm WindowManager getSystemService WINDOW_SERVICE wm.addView mView params Now you will start getting..
Lock the android device programatically http://stackoverflow.com/questions/4545079/lock-the-android-device-programatically savedInstanceState mDPM DevicePolicyManager getSystemService Context.DEVICE_POLICY_SERVICE mDeviceAdminSample new ComponentName..
Android: Taking complete control of phone(kiosk mode), is it possible? How? http://stackoverflow.com/questions/7121508/android-taking-complete-control-of-phonekiosk-mode-is-it-possible-how TelephonyManager telephonymanager TelephonyManager getSystemService TELEPHONY_SERVICE telephonymanager.listen phoneStateListener.. try TelephonyManager manager TelephonyManager context.getSystemService Context.TELEPHONY_SERVICE Class c Class.forName manager.getClass.. public void run ActivityManager actMngr ActivityManager getSystemService Context.ACTIVITY_SERVICE while isContinue try Maintain a boolean..
Close/hide the Android Soft Keyboard http://stackoverflow.com/questions/1109022/close-hide-the-android-soft-keyboard passing in the token of the window containing your edit field. InputMethodManager imm InputMethodManager getSystemService Context.INPUT_METHOD_SERVICE imm.hideSoftInputFromWindow myEditText.getWindowToken 0 This will force the keyboard to be..
Android: Binding data from a database to a CheckBox in a ListView? http://stackoverflow.com/questions/1505751/android-binding-data-from-a-database-to-a-checkbox-in-a-listview cur @Override public View newView Context context Cursor cur ViewGroup parent LayoutInflater li LayoutInflater getSystemService Context.LAYOUT_INFLATER_SERVICE return li.inflate R.layout.mylist parent false @Override public void bindView View view..
How to check internet access on Android? InetAddress never timeouts http://stackoverflow.com/questions/1560788/how-to-check-internet-access-on-android-inetaddress-never-timeouts need to add a null check. Modified solution below public boolean isOnline ConnectivityManager cm ConnectivityManager getSystemService Context.CONNECTIVITY_SERVICE NetworkInfo netInfo cm.getActiveNetworkInfo if netInfo null netInfo.isConnectedOrConnecting..
Android: I want to shake it http://stackoverflow.com/questions/2317428/android-i-want-to-shake-it mSensorListener super.onPause And add this to your onCreate method do this in onCreate mSensorManager SensorManager getSystemService Context.SENSOR_SERVICE mSensorManager.registerListener mSensorListener mSensorManager.getDefaultSensor Sensor.TYPE_ACCELEROMETER..
How to find serial number of Android device? http://stackoverflow.com/questions/2322234/how-to-find-serial-number-of-android-device in my app android serial number share improve this question TelephonyManager tManager TelephonyManager myActivity.getSystemService Context.TELEPHONY_SERVICE String uid tManager.getDeviceId getSystemService is a method from the Activity class. getDeviceID.. tManager TelephonyManager myActivity.getSystemService Context.TELEPHONY_SERVICE String uid tManager.getDeviceId getSystemService is a method from the Activity class. getDeviceID will return the MDN or MEID of the device depending on which radio the..
Detect application heap size in Android http://stackoverflow.com/questions/2630158/detect-application-heap-size-in-android is allowed to use. For item 2 above getMemoryClass which can be invoked as follows ActivityManager am ActivityManager getSystemService ACTIVITY_SERVICE int memoryClass am.getMemoryClass Log.v onCreate memoryClass Integer.toString memoryClass This method tells..
Download a file with Android, and showing the progress in a ProgressDialog http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog prevent CPU from going off if the user presses the power button during download PowerManager pm PowerManager context.getSystemService Context.POWER_SERVICE PowerManager.WakeLock wl pm.newWakeLock PowerManager.PARTIAL_WAKE_LOCK getClass .getName wl.acquire.. name of the file.ext get download service and enqueue file DownloadManager manager DownloadManager getSystemService Context.DOWNLOAD_SERVICE manager.enqueue request Download progress will be showing in the notification bar. Final thoughts..
Programmatically switching off Android phone http://stackoverflow.com/questions/3745523/programmatically-switching-off-android-phone in Android I am using following snippet but it didn't work for me. KeyguardManager keyguardManager KeyguardManager getSystemService Activity.KEYGUARD_SERVICE KeyguardLock lock keyguardManager.newKeyguardLock KEYGUARD_SERVICE lock.disableKeyguard to disable..
Android - Camera preview is sideways http://stackoverflow.com/questions/3841122/android-camera-preview-is-sideways if isPreviewRunning mCamera.stopPreview Parameters parameters mCamera.getParameters Display display WindowManager getSystemService WINDOW_SERVICE .getDefaultDisplay if display.getRotation Surface.ROTATION_0 parameters.setPreviewSize height width mCamera.setDisplayOrientation..
Android - detect whether there is an Internet connection available [duplicate] http://stackoverflow.com/questions/4238921/android-detect-whether-there-is-an-internet-connection-available is available. private boolean isNetworkAvailable ConnectivityManager connectivityManager ConnectivityManager getSystemService Context.CONNECTIVITY_SERVICE NetworkInfo activeNetworkInfo connectivityManager.getActiveNetworkInfo return activeNetworkInfo..
Example: Communication between Activity and Service using Messaging http://stackoverflow.com/questions/4300291/example-communication-between-activity-and-service-using-messaging new TimerTask public void run onTimerTick 0 100L isRunning true private void showNotification nm NotificationManager getSystemService NOTIFICATION_SERVICE In this sample we'll use the same text for the ticker and the expanded notification CharSequence text..
How to programatically create and read WEP/EAP WiFi configurations in Android? http://stackoverflow.com/questions/4374862/how-to-programatically-create-and-read-wep-eap-wifi-configurations-in-android exposes the interface to create the same. Here is the sample code void saveWepConfig WifiManager wifi WifiManager getSystemService Context.WIFI_SERVICE WifiConfiguration wc new WifiConfiguration wc.SSID SSID_NAME IMP This should be in Quotes wc.hiddenSSID.. wc.wepKeys 0 aaabbb1234 This is the WEP Password wc.wepTxKeyIndex 0 WifiManager wifiManag WifiManager this.getSystemService WIFI_SERVICE boolean res1 wifiManag.setWifiEnabled true int res wifi.addNetwork wc Log.d WifiPreference add Network returned.. programatically Straighforward again. Here is the sample code void readWepConfig WifiManager wifi WifiManager getSystemService Context.WIFI_SERVICE List WifiConfiguration item wifi.getConfiguredNetworks int i item.size Log.d WifiPreference NO OF CONFIG..
creating a system overlay (always on top) button in android http://stackoverflow.com/questions/4481226/creating-a-system-overlay-always-on-top-button-in-android params.gravity Gravity.RIGHT Gravity.TOP params.setTitle Load Average WindowManager wm WindowManager getSystemService WINDOW_SERVICE wm.addView mView params @Override public void onDestroy super.onDestroy Toast.makeText getBaseContext onDestroy.. onDestroy super.onDestroy Toast.makeText getBaseContext onDestroy Toast.LENGTH_LONG .show if mView null WindowManager getSystemService WINDOW_SERVICE .removeView mView mView null class HUDView extends ViewGroup private Paint mLoadPaint public HUDView Context.. params.gravity Gravity.RIGHT Gravity.TOP params.setTitle Load Average WindowManager wm WindowManager getSystemService WINDOW_SERVICE wm.addView mView params Now you will start getting each and every click event. So you need to rectify in..
Lock the android device programatically http://stackoverflow.com/questions/4545079/lock-the-android-device-programatically protected void onCreate Bundle savedInstanceState super.onCreate savedInstanceState mDPM DevicePolicyManager getSystemService Context.DEVICE_POLICY_SERVICE mDeviceAdminSample new ComponentName Controller.this adminActivity.class To lock the device..
Android: Taking complete control of phone(kiosk mode), is it possible? How? http://stackoverflow.com/questions/7121508/android-taking-complete-control-of-phonekiosk-mode-is-it-possible-how super.onCreate StateListener phoneStateListener new StateListener TelephonyManager telephonymanager TelephonyManager getSystemService TELEPHONY_SERVICE telephonymanager.listen phoneStateListener PhoneStateListener.LISTEN_CALL_STATE catch Exception e class.. and disconnect the call programmatically try TelephonyManager manager TelephonyManager context.getSystemService Context.TELEPHONY_SERVICE Class c Class.forName manager.getClass .getName Method m c.getDeclaredMethod getITelephony m.setAccessible.. val public void startThread isContinue true start public void run ActivityManager actMngr ActivityManager getSystemService Context.ACTIVITY_SERVICE while isContinue try Maintain a boolean isyourapprunning to know if your app was running or not......
|