【问题标题】:How can i save PendingIntent to SQLite database?如何将 PendingIntent 保存到 SQLite 数据库?
【发布时间】:2016-11-14 10:31:04
【问题描述】:

我得到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一样的效果?

【问题讨论】:

  • 您是否找到了将其保存到数据库并检索以启动应用程序的方法?

标签: android android-intent android-pendingintent


【解决方案1】:

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

这样做的方式是通过 Android 中的绑定器机制与原始目标建立连接。即使您将PendingIntent 保存到Parcel,当您恢复PendingIntent 时,它仍然会与原始对象建立连接,因为它保存了连接令牌。

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

【讨论】:

    猜你喜欢
    • 2018-08-03
    • 1970-01-01
    • 2015-07-19
    • 2020-11-30
    • 1970-01-01
    • 2013-01-18
    • 2021-06-05
    • 2020-02-10
    • 1970-01-01
    相关资源
    最近更新 更多