List of usage examples for android.app ActivityManager getRunningServices
@Deprecated public List<RunningServiceInfo> getRunningServices(int maxNum) throws SecurityException
From source file:com.hagreve.android.HaGreveActivity.java
private boolean isServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.hagreve.android.service.HaGreveUpdateService".equals(service.service.getClassName())) { return true; }/*from ww w . j av a 2 s.c om*/ } return false; }
From source file:ch.luethi.skylinestracker.MainActivity.java
private boolean isPositionServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (PositionService.class.getName().equals(service.service.getClassName())) { return true; }/*from ww w . j a v a 2s . com*/ } return false; }
From source file:com.mplayer_remote.RemoteControl.java
/** * Sprawdza czy usuga ConnectAndPlayService dziaa w tle. * @return <code>true</code> jeli usuga ConnectAndPlayService dziaa w tle, <code>false</code> w przeciwnym wypadku. *//*from w w w. j a v a 2 s . c o m*/ private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if ("com.mplayer_remote.ConnectAndPlayService".equals(service.service.getClassName())) { return true; } } this.finish(); //to finish activity when user close mplayer by other whey return false; }
From source file:ca.etsmtl.applets.etsmobile.NewsListActivity.java
private boolean serviceIsRunning() { final ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (final RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (service.service.getClassName().equals(NewsListActivity.SERVICE)) { return true; }/* w ww.j a v a2s . c o m*/ } return false; }
From source file:com.pagenews.zhihudaily.homepage.MainActivity.java
@Override protected void onDestroy() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (CacheService.class.getName().equals(service.service.getClassName())) { stopService(new Intent(this, CacheService.class)); }//from ww w. ja v a2 s . c o m } super.onDestroy(); }
From source file:com.nachtimwald.android.serviceexplorer.ServiceListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_servicelist, container, false); ListView lv = (ListView) view.findViewById(R.id.serviceList); List<Map<String, String>> serviceData = new ArrayList<>(); if (getArguments().getBoolean("allServices")) { for (PackageInfo packageInfo : getActivity().getPackageManager() .getInstalledPackages(PackageManager.GET_SERVICES)) { if (packageInfo.services == null) { continue; }/*from www . j av a 2 s .c o m*/ for (ServiceInfo serviceInfo : packageInfo.services) { Map<String, String> datum = new HashMap<>(); datum.put("name", serviceInfo.name); datum.put("package", serviceInfo.packageName); datum.put("search", serviceInfo.name.replace(".", " ").replace("$", " ")); serviceData.add(datum); } } } else { ActivityManager activityManager = (ActivityManager) getActivity() .getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningServiceInfo> runningServiceInfos = activityManager .getRunningServices(Integer.MAX_VALUE); for (ActivityManager.RunningServiceInfo info : runningServiceInfos) { Map<String, String> datum = new HashMap<>(); datum.put("name", info.service.getClassName()); datum.put("package", info.service.getPackageName()); datum.put("search", info.service.getClassName().replace(".", " ").replace("$", " ")); serviceData.add(datum); } } mServicesAdapter = new SimpleAdapter(getActivity(), serviceData, android.R.layout.simple_list_item_2, new String[] { "name", "package", "search" }, new int[] { android.R.id.text1, android.R.id.text2, 0 }); lv.setAdapter(mServicesAdapter); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Intent i = new Intent(getActivity(), DetailActivity.class); i.putExtra("name", ((HashMap<String, String>) parent.getItemAtPosition(position)).get("name")); i.putExtra("package", ((HashMap<String, String>) parent.getItemAtPosition(position)).get("package")); startActivity(i); } }); if (savedInstanceState != null) { lv.onRestoreInstanceState(savedInstanceState.getParcelable(STATE_LISTPOS)); } return view; }
From source file:com.app.sniffy.MainActivity.java
private boolean isMyServiceRunning() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (SentBoxService.class.getName().equals(service.service.getClassName())) { return true; }//ww w . j av a2s .c o m } return false; }
From source file:org.csploit.android.core.System.java
public static boolean isServiceRunning(String name) { ActivityManager manager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE); //noinspection ConstantConditions for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (name.equals(service.service.getClassName())) return true; }/*from ww w .java 2 s . c o m*/ return false; }
From source file:pl.zajecia.cw3.MainActivity.java
/** * Checks if main service is already started. * Necessary in order not to mess with intervals * (e.g register more than one broadcasts) */// w w w . j av a2s .c om private boolean isServiceStarted() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MainService.class.getName().equals(service.service.getClassName())) { return true; } } return false; }
From source file:com.odo.kcl.mobileminer.activities.MainActivity.java
private boolean miningActive() { ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { if (MinerService.class.getName().equals(service.service.getClassName())) { return true; }/*from w ww .j av a2 s. com*/ } return false; }