Ejemplo n.º 1
0
 public void startTestService() {
   startService(new Intent(this, TestService.class));
   Intent aaaa = new Intent();
   int androidVersion = ServiceUtils.getSDKVersionNumber();
   if (androidVersion >= 21) {
     // 只一句至关重要,对于android5.0以上,所以minSdkVersion最好小于21;
     aaaa.setPackage(getPackageName());
   }
   aaaa.setAction("common.het.com.library.intent.action.TestService");
   boolean mIsBound = bindService(aaaa, conn, Context.BIND_AUTO_CREATE);
   if (!mIsBound) {
     Logc.e("初始化service失败..mService=" + " mConnection=" + conn);
   } else {
     Logc.i(
         "成功初始化ServiceManager App.packageName="
             + getPackageName()
             + " mService="
             + " mConnection="
             + conn);
   }
 }
Ejemplo n.º 2
0
 public void onServiceConnected(ComponentName name, IBinder service) {
   Logc.i("======================================================onServiceConnected===");
 }
Ejemplo n.º 3
0
 public void onServiceDisconnected(ComponentName name) {
   Logc.i(
       "===========================================================onServiceDisconnected===");
 }