Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.08 KB | None | 0 0
  1. public class Service extends android.app.Service {
  2.  
  3.     Handler h = new Handler();
  4.  
  5.     Runnable task = new Runnable() {
  6.         @Override
  7.         public void run() {
  8.             ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
  9.             List<ActivityManager.RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
  10.             Log.d("tag", "chack!!!!!!!!!!!!!!!!");
  11.             for (int i = 0; i < procInfos.size(); i++) {
  12.                 if (procInfos.get(i).processName.equals("com.mwdn.pricechecker")) {
  13.                     h.postDelayed(task, 20_000);
  14.                     return;
  15.                 }
  16.             }
  17.  
  18.             Intent i = getPackageManager().getLaunchIntentForPackage("com.mwdn.pricechecker");
  19.             startActivity(i);
  20.             h.postDelayed(task, 20_000);
  21.         }
  22.     };
  23.  
  24.     @Nullable
  25.     @Override
  26.     public IBinder onBind(Intent intent) {
  27.         return null;
  28.     }
  29.  
  30.     @Override
  31.     public void onCreate() {
  32.         super.onCreate();
  33.         h.postDelayed(task, 10_000);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement