Update missed calls notification on android -
i need cancel missed calls notification number. i've seen notificationmgr class on com.android.phone i'm unable call trough reflection. there other way?
the code below cancel missed call notification.
to method work correctly, must gain modify_phone_state permission in androidmanifest.xml like
<uses-permission android:name="android.permission.modify_phone_state"></uses-permission>
in androidmanifest.xml
string log_tag = "log"; try { class servicemanagerclass = class.forname("android.os.servicemanager"); method getservicemethod = servicemanagerclass.getmethod("getservice", string.class); object phoneservice = getservicemethod.invoke(null, "phone"); class itelephonyclass = class.forname("com.android.internal.telephony.itelephony"); class itelephonystubclass = null; for(class clazz : itelephonyclass.getdeclaredclasses()) { if (clazz.getsimplename().equals("stub")) { itelephonystubclass = clazz; break; } } if (itelephonystubclass != null) { class ibinderclass = class.forname("android.os.ibinder"); method asinterfacemethod = itelephonystubclass.getdeclaredmethod("asinterface", ibinderclass); object itelephony = asinterfacemethod.invoke(null, phoneservice); if (itelephony != null) { method cancelmissedcallsnotificationmethod = itelephony.getclass().getmethod( "cancelmissedcallsnotification"); cancelmissedcallsnotificationmethod.invoke(itelephony); } else { log.w(log_tag, "telephony service null, can't call " + "cancelmissedcallsnotification"); } } else { log.d(log_tag, "unable locate itelephony.stub class!"); } } catch (classnotfoundexception ex) { log.e(log_tag, "failed clear missed calls notification due classnotfoundexception!", ex); } catch (invocationtargetexception ex) { log.e(log_tag, "failed clear missed calls notification due invocationtargetexception!", ex); } catch (nosuchmethodexception ex) { log.e(log_tag, "failed clear missed calls notification due nosuchmethodexception!", ex); } catch (throwable ex) { log.e(log_tag, "failed clear missed calls notification due throwable!", ex); }
the original link http://sites.google.com/site/t2k269group/development-diary/reset-missed-calls-notification
if know how use reflection access class in com.android.phone, please tell me.
Comments
Post a Comment