我得到NotificationListenerService来拦截Notification并清除,然后想拦截保存到数据库的PendingIntent的Notification,但PendingIntent没有序列化,所以我想获取PendingIntend内部Intent然后使用intent.toUri( )序列化保存的方法到数据库,但这次出现问题,当我在调用startActivity(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效果相同?
答案 0 :(得分:1)
我认为你误解了PendingIntent
的目的。它应该用于触发应用程序中包含的Intent
不同于原始的PendingIntent
,但具有相同的权限。这是您可以启动其他应用程序内部活动的方法。
它的方式是通过Android中的binder机制与原始目标建立连接。即使您将Parcel
保存到PendingIntent
,当您还原Intent
时,它仍将与原始对象建立连接,因为它会保存连接令牌。
但是,您所做的是从PendingIntent
撕掉PendingIntent
并尝试启动它。它会尝试从您无法访问的原始应用程序启动活动。不幸的是,我没有找到将 <?php
$resultdata[0] = array(
"daynumber" => 15,
"dayname" =>'Tue',
"infomation" => array('baller', 'ROller','','gtk')
);
$resultdata[1] = array(
"daynumber" => 15,
"dayname" =>'Tue',
"infomation" => array('nomal', 'Goildt')
);
$resultdata[2] = array(
"daynumber" => 24,
"dayname" =>'Thur',
"infomation" => array('goon' => 'Volley', 'Foller')
);
$counter = 0;
foreach($resultdata as $veliu){
$newinfo = implode(':*:', $veliu["infomation"]);
$veliu["infomation"] = $newinfo;
$temporryry[$counter] = $veliu;
$counter++;
}
function multiarray_merge($result_arr, $key){
foreach($result_arr as $val){
$item = $val[$key];
foreach($val as $k=>$v){
$arr[$item][$k][] = $v;
}
}
// Combine unique entries into a single array
// and non-unique entries into a single element
foreach($arr as $key=>$val){
foreach($val as $k=>$v){
$field = array_unique($v);
if(count($field) == 1){
$field = array_values($field);
$field = $field[0];
$arr[$key][$k] = $field;
} else {
$arr[$key][$k] = $field;
}
}
}
return $arr;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet">
<style type="text/stylesheet">
font-family: 'Varela Round', sans-serif;
</style>
</head>
<body>
<pre>
<?php
$newarray = multiarray_merge($temporryry, 'daynumber');
$count = 0;
$counte = 0;
foreach($newarray as $vel){
$notin = $vel["infomation"];
if(is_array($notin)){
foreach($notin as $jin){
$reve = explode(":*:", $jin);
$good[$counte] = $reve;
$counte++;
}
}else{
$reve = explode(":*:", $notin);
$good= $reve;
}
$vel["infomation"] = $good;
$finalsolution[$count] = $vel;
$count++;
}
print_r($finalsolution);
?>
</pre>
</body>
</html>
保存到数据库的方法,因为您需要保存我提到的令牌,并且没有可靠的方法来获取它。它甚至不存储在Java代码中。