List of usage examples for android.app ActivityManager getRunningServices
@Deprecated public List<RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException
From source file:ch.bfh.instacircle.NetworkActiveActivity.java
/** * checks whether the NetworkService is running or not * /*from ww w. j a v a 2 s . c o m*/ * @return true if service is running, false otherwise */ public boolean isServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("ch.bfh.instacircle.service.NetworkService".equals(service.service.getClassName())) { return true; } } return false; }
From source file:com.geecko.QuickLyric.fragment.LocalLyricsFragment.java
private boolean isMyServiceRunning(Context context) { ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (BatchDownloaderService.class.getName().equals(service.service.getClassName())) { return true; }//from ww w . java 2s . com } Log.i("Service not", "running"); return false; }
From source file:system.info.reader.java
public String refresh() { //wifi/*from w ww . j a v a2 s .co m*/ WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); if ((wifiInfo != null) && (wifiInfo.getMacAddress() != null)) Properties.setInfo((String) propertyItems[4], wifiInfo.getMacAddress()); else Properties.setInfo((String) propertyItems[4], "not avaiable"); //String tmpsdcard = runCmd("df", ""); //if (tmpsdcard != null) result += tmpsdcard + "\n\n"; //setMap("dpi", dpi); //location LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); List ll = lm.getProviders(true); Boolean foundLoc = false; for (int i = 0; i < ll.size(); i++) { Location lo = lm.getLastKnownLocation((String) ll.get(i)); if (lo != null) { Properties.setInfo((String) propertyItems[3], lo.getLatitude() + ":" + lo.getLongitude()); foundLoc = true; break; } } if (!foundLoc) Properties.setInfo((String) propertyItems[3], getString(R.string.locationHint)); ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); List serviceList = am.getRunningServices(10000); serviceInfo = ""; for (int i = 0; i < serviceList.size(); i++) { RunningServiceInfo rs = (RunningServiceInfo) serviceList.get(i); serviceInfo += rs.service.flattenToShortString() + "\n"; } //result += getString(R.string.nService) + serviceList.size() + "\n";//service number psInfo = ""; List appList = am.getRunningAppProcesses(); for (int i = 0; i < appList.size(); i++) { RunningAppProcessInfo as = (RunningAppProcessInfo) appList.get(i); psInfo += as.processName + "\n"; } //result += getString(R.string.nProcess) + appList.size() + "\n";//process number taskInfo = ""; List taskList = am.getRunningTasks(10000); for (int i = 0; i < taskList.size(); i++) { RunningTaskInfo ts = (RunningTaskInfo) taskList.get(i); taskInfo += ts.baseActivity.flattenToShortString() + "\n"; } //result += getString(R.string.nTask) + taskList.size() + "\n\n";//task number //result += getString(R.string.nProcess) + runCmd("ps", "") + "\n";//process number //setMap(getString(R.string.nApk), nApk); //send message to let view redraw. Message msg = mRedrawHandler.obtainMessage(); mRedrawHandler.sendMessage(msg); //properListItemAdapter.notifyDataSetChanged();//no use? Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vibrator.vibrate(400); return ""; }
From source file:by.zatta.pilight.MainActivity.java
boolean isConnectionServiceActive() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (ConnectionService.class.getName().equals(service.service.getClassName())) { return true; }/*from w w w. ja v a2 s . co m*/ } return false; }
From source file:com.openarc.nirmal.nestle.LoginActivity.java
private boolean isRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (DataDownloadService.class.getName().equals(service.service.getClassName())) { return true; }/*from ww w . j a v a 2s .c o m*/ } return false; }
From source file:com.packetsender.android.MainActivity.java
public RunningServiceInfo getServiceIntent() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.packetsender.android.PacketListenerService".equals(service.service.getClassName())) { return service; }//from w w w . java2s . c o m } return null; }
From source file:com.flyingcrop.ScreenCaptureFragment.java
public boolean ServiceIsRunning() { ActivityManager manager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.flyingcrop.Brush".equals(service.service.getClassName())) { return true; }/* w ww.j a v a 2 s .com*/ } return false; }
From source file:de.da_sense.moses.client.WelcomeActivity.java
/** * Checks if is MoSeS service running.//from w ww.jav a 2s . c o m * * @return true, if Moses service is running */ private boolean isMosesServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { String serviceName = service.service.getClassName(); Log.d(LOG_TAG, "service name: " + serviceName); if (MosesService.class.getName().equals(service.service.getClassName())) { return true; } } return false; }
From source file:org.androidpn.client.NotificationReceiver.java
/** * ????/*from w ww. j a v a 2 s.c o m*/ * * @param context * @param serviceName * ??+???net.loonggg.testbackstage.TestService * @return true?false?? */ public boolean isServiceWork(Context context, String serviceName) { boolean isWork = false; ActivityManager myAM = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List<RunningServiceInfo> myList = myAM.getRunningServices(40); if (myList.size() <= 0) { return false; } for (int i = 0; i < myList.size(); i++) { String mName = myList.get(i).service.getClassName().toString(); if (mName.equals(serviceName)) { isWork = true; break; } } return isWork; }
From source file:ti.modules.titanium.android.AndroidModule.java
@Kroll.method public boolean isServiceRunning(IntentProxy intentProxy) { Intent intent = intentProxy.getIntent(); if (intent == null) { Log.w(TAG, "isServiceRunning called with empty intent. Will return false, but value is meaningless."); return false; }//from w ww.j a v a2 s. c o m TiApplication app = TiApplication.getInstance(); if (app == null) { Log.w(TAG, "Application instance is no longer available. Unable to check isServiceRunning. Returning false though value is meaningless."); return false; } ActivityManager am = (ActivityManager) app.getApplicationContext() .getSystemService(Context.ACTIVITY_SERVICE); if (am != null) { List<RunningServiceInfo> services = am.getRunningServices(Integer.MAX_VALUE); for (RunningServiceInfo service : services) { if (service.service.equals(intent.getComponent())) { return true; } } } return false; }