android - Reliable way of retrieving StatusbarNotification details (title, notification text) -


i'd information out of statusbarnotification-object possible. right now, "reliable" information can accessed tickertext-property. i'm using following code notification's title , text via remoteviews, lot of time, title and/or text null :-(:

    //get title , text     string mtitle = "";     string mtext = "";     try {         remoteviews remoteview = sbn.getnotification().contentview;         layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service);         viewgroup localview = (viewgroup) inflater.inflate(remoteview.getlayoutid(), null);         remoteview.reapply(getapplicationcontext(), localview);         textview tvtitle = (textview) localview.findviewbyid(android.r.id.title);         textview tvtext = (textview) localview.findviewbyid(16908358);         mtitle = (string)tvtitle.gettext();         mtext = (string)tvtext.gettext();     } catch (exception e){         log.e(tag, "error getting notification title/text: " + e);     } 

is there alternative (more reliable) way? "hand-code" resource ids "popular" notifications gmail, sms, etc., may break @ time when apps updated. thanks!

with android 4.4(kitkat), api level 19 can use notification.extras attibute notification title,text,....

http://gmariotti.blogspot.com/2013/11/notificationlistenerservice-and-kitkat.html


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -