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

PendingIntent实现原理和代码

 2011-07-01 20:49:06 来源:本站整理   
核心提示: mResultData = data; mResultExtras = extras; if (mHandler == null) { run(); } else { mHandler.post(this); } } public void run() { mWho.onSendFinished(

       mResultData = data;
       mResultExtras = extras;
       if (mHandler == null) {
         run();
       } else {
         mHandler.post(this);
       }
     }
     public void run() {
       mWho.onSendFinished(mPendingIntent, mIntent, mResultCode,
           mResultData, mResultExtras);
     }
   }

   public static PendingIntent getActivity(Context context, int requestCode,
       Intent intent, int flags) {
     String packageName = context.getPackageName();
     String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
         context.getContentResolver()) : null;
     try {
       IIntentSender target =
         ActivityManagerNative.getDefault().getIntentSender(
           IActivityManager.INTENT_SENDER_ACTIVITY, packageName,
           null, null, requestCode, intent, resolvedType, flags);
       return target != null ? new PendingIntent(target) : null;
     } catch (RemoteException e) {
     }
     return null;
   }

   public static PendingIntent getBroadcast(Context context, int requestCode,
       Intent intent, int flags) {
     String packageName = context.getPackageName();
     String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
         context.getContentResolver()) : null;
     try {
       IIntentSender target =
         ActivityManagerNative.getDefault().getIntentSender(
           IActivityManager.INTENT_SENDER_BROADCAST, packageName,
           null, null, requestCode, intent, resolvedType, flags);
       return target != null ? new PendingIntent(target) : null;
     } catch (RemoteException e) {
     }
     return null;
   }

   public static PendingIntent getService(Context context, int requestCode,
       Intent intent, int flags) {
     String packageName = context.getPackageName();
     String resolvedType = intent != null ? intent.resolveTypeIfNeeded(
         context.getContentResolver()) : null;
     try {
       IIntentSender target =
         ActivityManagerNative.getDefault().getIntentSender(

上一页  1 2 3 4  下一页

Tags:PendingIntent 实现 原理

编辑录入:coldstar [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接