PendingIntent实现原理和代码
2011-07-01 20:49:06 来源:本站整理.mTarget.asBinder());
}
return false;
}
@Override
public int hashCode() {
return mTarget.asBinder().hashCode();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(128);
sb.append("PendingIntent{");
sb.append(Integer.toHexString(System.identityHashCode(this)));
sb.append(": ");
sb.append(mTarget != null ? mTarget.asBinder() : null);
sb.append('}');
return sb.toString();
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel out, int flags) {
out.writeStrongBinder(mTarget.asBinder());
}
public static final Parcelable.Creator<PendingIntent> CREATOR
= new Parcelable.Creator<PendingIntent>() {
public PendingIntent createFromParcel(Parcel in) {
IBinder target = in.readStrongBinder();
return target != null ? new PendingIntent(target) : null;
}
public PendingIntent[] newArray(int size) {
return new PendingIntent[size];
}
};
public static void writePendingIntentOrNullToParcel(PendingIntent sender,
Parcel out) {
out.writeStrongBinder(sender != null ? sender.mTarget.asBinder()
: null);
}
public static PendingIntent readPendingIntentOrNullFromParcel(Parcel in) {
IBinder b = in.readStrongBinder();
return b != null ? new PendingIntent(b) : null;
}
/*package*/ PendingIntent(IIntentSender target) {
mTarget = target;
}
/*package*/ PendingIntent(IBinder target) {
mTarget = IIntentSender.Stub.asInterface(target);
}
/** @hide */
public IIntentSender getTarget() {
return mTarget;
}
}
整体来说PendingIntent的实现比较简单,主要和Android特定的的远程服务打交道(短信、通知、闹铃等),通常的应用无需使用。
Tags:PendingIntent 实现 原理
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接