我有一个 Android 库,它有一个Service创建Notification. 据我了解,Notification必须设置contentIntent( PendingIntent) 否则将引发运行时异常。
问题是我希望用户能够按Service原样使用它,或者扩展它,以便他们可以PendingIntent在创建Notification. 但是,如果他们选择不这样做,我需要将其设置PendingIntent为某些东西,以免出现异常。有什么方法可以创建一个PendingIntent仅充当填充的假人吗?
以下是该方法的代码示例createNotification:
PendingIntent p;
if(getPendingIntentCallback != null) {
    p = getPendingIntentCallback.getPendingIntent();
}
else {
    p = ?;
}
notification.contentIntent = p;