WEB开发网
开发学院手机开发Android 开发 PendingIntent实现原理和代码 阅读

PendingIntent实现原理和代码

 2011-07-01 20:49:06 来源:本站整理   
核心提示: IActivityManager.INTENT_SENDER_SERVICE, packageName, null, null, requestCode, intent, resolvedType, flags); return target != null ? new PendingIntent(target

           IActivityManager.INTENT_SENDER_SERVICE, packageName,
           null, null, requestCode, intent, resolvedType, flags);
       return target != null ? new PendingIntent(target) : null;
     } catch (RemoteException e) {
     }
     return null;
   }

   public IntentSender getIntentSender() {
     return new IntentSender(mTarget);
   }

   public void cancel() {
     try {
       ActivityManagerNative.getDefault().cancelIntentSender(mTarget);
     } catch (RemoteException e) {
     }
   }

   public void send() throws CanceledException {
     send(null, 0, null, null, null);
   }

   public void send(int code) throws CanceledException {
     send(null, code, null, null, null);
   }

   public void send(Context context, int code, Intent intent)
       throws CanceledException {
     send(context, code, intent, null, null);
   }

   public void send(int code, OnFinished onFinished, Handler handler)
       throws CanceledException {
     send(null, code, null, onFinished, handler);
   }

   public void send(Context context, int code, Intent intent,
       OnFinished onFinished, Handler handler) throws CanceledException {
     try {
       String resolvedType = intent != null ?
           intent.resolveTypeIfNeeded(context.getContentResolver())
           : null;
       int res = mTarget.send(code, intent, resolvedType,
           onFinished != null
           ? new FinishedDispatcher(this, onFinished, handler)
           : null);
       if (res < 0) {
         throw new CanceledException();
       }
     } catch (RemoteException e) {
       throw new CanceledException(e);
     }
   }

   public String getTargetPackage() {
     try {
       return ActivityManagerNative.getDefault()
         .getPackageForIntentSender(mTarget);
     } catch (RemoteException e) {
       // Should never happen.
       return null;
     }
   }

   @Override
   public boolean equals(Object otherObj) {
     if (otherObj instanceof PendingIntent) {
       return mTarget.asBinder().equals(((PendingIntent)otherObj)

上一页  1 2 3 4  下一页

Tags:PendingIntent 实现 原理

编辑录入:coldstar [复制链接] [打 印]
赞助商链接