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