REG*_*EG1 6 android android-intent runtimeexception
我正在尝试将一组StatusBarNotifications发送给我的另一个服务,所以我这样做了:
扩展的服务NotificationListenerService:
@Override
public void onNotificationPosted(StatusBarNotification sbn) {
// TODO Auto-generated method stub
StatusBarNotification[] activeN = super.getActiveNotifications();
Intent i = new Intent(this, CoreTwo.class);
i.putExtra("activenotifications", activeN);
startService(i);
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个关于文件描述符的RuntimeException.
我只找到几个环节解决这一问题,例如这一个在这里.答案提到了以下内容:
使用Bundle.putBinder()传递一个Binder,它将使用ParcelFileDescriptor(来自API 18)返回一个Parcel.但我不明白如何实现这一点.
此链接中的另一个人在这里提到以下内容:
如果我从ContentProvider返回PaecelFileDescriptor,它可以正常工作.
但我不明白他的意思.
最后一个环节是这个位置.它解决了与我相同的问题,但似乎没有解决方案.
有人理解我链接的这些潜在解决方案吗?是否有针对此问题的解决方法,可能是另一种发送数据的方式(StatusBarNotification [](它扩展了Parcelable))?
这是日志:
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): Error running onNotificationPosted
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): java.lang.RuntimeException: Not allowed to write file descriptors here
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.nativeAppendFrom(Native Method)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.appendFrom(Parcel.java:431)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Bundle.writeToParcel(Bundle.java:1679)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.writeBundle(Parcel.java:636)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.app.Notification.writeToParcel(Notification.java:962)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.service.notification.StatusBarNotification.writeToParcel(StatusBarNotification.java:106)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.writeParcelable(Parcel.java:1285)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.writeParcelableArray(Parcel.java:1984)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.writeValue(Parcel.java:1248)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.writeArrayMapInternal(Parcel.java:618)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Bundle.writeToParcel(Bundle.java:1692)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Parcel.writeBundle(Parcel.java:636)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.content.Intent.writeToParcel(Intent.java:7013)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.app.ActivityManagerProxy.startService(ActivityManagerNative.java:2975)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1506)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.app.ContextImpl.startService(ContextImpl.java:1488)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.content.ContextWrapper.startService(ContextWrapper.java:494)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at com.project.now.NoLiSe.onNotificationPosted(NoLiSe.java:18)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.service.notification.NotificationListenerService$INotificationListenerWrapper.onNotificationPosted(NotificationListenerService.java:168)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.service.notification.INotificationListener$Stub.onTransact(INotificationListener.java:56)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at android.os.Binder.execTransact(Binder.java:404)
08-23 16:49:36.839: W/NotificationListenerService[NoLiSe](12804): at dalvik.system.NativeStart.run(Native Method)
Run Code Online (Sandbox Code Playgroud)
非常感谢这里的一些帮助,因为我无法解决这个问题,而且它已经开始向我倾斜了,谢谢
| 归档时间: |
|
| 查看次数: |
1130 次 |
| 最近记录: |