PendingIntent实现原理和代码
2011-07-01 20:49:06 来源:本站整理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(
Tags:PendingIntent 实现 原理
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接