Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了android – 如何将PendingIntent保存到SQLite数据库?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我得到NotificationListenerservice来拦截Notification并清除,然后想拦截PendingIntent的Notification保存到数据库,但PendingIntent没有序列化,所以我想获取PendingIntend内部的Intent然后使用intent.toUri()方法序列化保存到数据库,但这次出现问题,当我在异常时调用startActivity(intent)后对Intent进行去同步:

Process: com.example.joee.cleardatademo,PID: 20441
                  java.lang.SecurityException: Permission Denial: starTing Intent { act=android.intent.action.VIEW flg=0x14008000 cmp=com.skype.raider/com.skype.android.app.main.HuBACtivity (has extras) } from ProcessRecord{4596be88 20441:com.example.joee.cleardatademo/u0a1647} (pid=20441,uid=11647) not exported from uid 11028
                      at android.os.Parcel.readException(Parcel.java:1474)
                      at android.os.Parcel.readException(Parcel.java:1427)
                      at android.app.ActivitymanagerProxy.startActivity(ActivitymanagerNative.java:2104)
                      at android.app.instrumentation.execStartActivity(instrumentation.java:1419)
                      at android.app.ContextImpl.startActivity(ContextImpl.java:1065)
                      at android.app.ContextImpl.startActivity(ContextImpl.java:1047)
                      at com.example.joee.cleardatademo.activity.notificationmanagerActivity$2$1.onClick(notificationmanagerActivity.java:110)
                      at android.view.View.performClick(View.java:4569)
                      at android.view.View$PerformClick.run(View.java:18570)
                      at android.os.Handler.handleCallBACk(Handler.java:733)
                      at android.os.Handler.dispatchmessage(Handler.java:95)
                      at android.os.Looper.loop(Looper.java:212)
                      at android.app.ActivityThread.main(ActivityThread.java:5151)
                      at java.lang.reflect.Method.invokeNative(Native Method)
                      at java.lang.reflect.Method.invoke(Method.java:515)
                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
                      at dalvik.system.NativeStart.main(Native Method)
I/Process: Sending signal. PID: 20441 SIG: 9
Disconnected from the target VM,address: 'localhost:8633',transport: 'socket'

我怎样才能将PendingIntent保存到数据库中?或者其他方法实现和保存PendingIntent效果相同?

解决方法

我认为你误解了PendingIntent的目的.它应该用于在不同于原始应用程序的应用程序中触发它包含的Intent,但具有相同的权限.这是您可以启动其他应用程序内部活动的方法.

它的方式是通过Android中的binder机制与原始目标建立连接.即使将PendingIntent保存到Parcel,当您还原PendingIntent时,它仍会与原始对象建立连接,因为它会保存连接令牌.

然而,你所做的是从PendingIntent中撕掉Intent并尝试启动它.它尝试从原始应用程序启动您无权访问的活动.不幸的是,我没有看到你将PendingIntent保存到数据库方法,因为你需要保存我提到的令牌,并且没有可靠的方法获取它.它甚至没有存储在Java代码中.

大佬总结

以上是大佬教程为你收集整理的android – 如何将PendingIntent保存到SQLite数据库?全部内容,希望文章能够帮你解决android – 如何将PendingIntent保存到SQLite数据库?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。