java


How to read notifications correctly on Android


I am developing an App for read notifications all my code work great, but have two problems. I use this code for read notifications:
String pack = sbn.getPackageName();
String ticker ="";
if(sbn.getNotification().tickerText !=null) {
ticker = sbn.getNotification().tickerText.toString();
}
Bundle extras = sbn.getNotification().extras;
String title = extras.getString("android.title");
//String text = extras.getCharSequence("android.text").toString();
String text = null;
if (extras.getCharSequence("android.text") != null) {
text =(String) extras.getCharSequence("android.text");
}
if (text == null) {
// for whatsapp on kitkat second whats app text
// will be null
if (extras.get("android.textLines") != null) {
CharSequence[] charText = (CharSequence[]) extras
.get("android.textLines");
if (charText.length > 0) {
text = charText[charText.length - 1].toString();
}
}
}
The code works, but the problem is with WhatsApp, when I receive more than one message I get the following structure.
Title: NameUser
Text: Hi, how are you? <---- This is ok!
but the second message I get
Title: NameUser
Text : Hi again! <--- This is ok;
Title: NameUser
Text: 2 New messages <---- Agggr that is wrong!!!!!
How can avoid the "2 New messages"??
And the second question is Can I get images send via whatsapp? For the moment I only get the following structure.
Title: NameUser
Text: Image
Thanks in advance
There is no way you can influence (from your app) what notifications are sent by some other app's server to your phone.

Related Links

Difference between Java Enumeration and Iterator
Servlet security authentication
Java API for Google Maps (or similar) [closed]
Live sorting of JTable
Is it possible to reference a nested generic parameter in java?
RESTlet: How to process multipart/form-data requests?
Create MySQL database from Java
Sum of fields of objects in objectarray, all within the constructor?
Lightest-weight spacer component in a GridBagLayout
How to make unique font color for lines in a JCombobox?
BIRT / WebSphere / Java 2 Security
Convert String to Code
How can I build a list of days, months, years from a calendar object in Java?
How would you change a single byte in a file?
How to configure Hibernate Tools HQL editor in Eclipse with a custom NamingStrategy
Large file uploads with Java applet

Categories

HOME
xamarin
log4j
pdf
netsuite
heroku
syntax
bookshelf.js
ip
angular-ui-bootstrap
fancybox
mouse
awesome-wm
primary-key
vifm
u-sql
vb.net-2010
dtrace
circuit
vaadin7
dosgi
clojurescript
highlight.js
pugjs
interop
samoa
lucene.net
java-3d
accessor
zurb-foundation-6
claims-based-identity
android-widget
buildbot
selectedindexchanged
fluentvalidation
elasticsearch-net
compatibility
google-cloud-nl
srcset
instant-messaging
key-value-observing
http-status-code-503
android-nestedscrollview
atl
y86
force-layout
hue
awt
eclipse-scout
jvm-languages
nand2tetris
eigenvalue
node-sass
network-flow
jedis
ionicons
fancybox-2
elgg
feeds
quartz-composer
google-cdn
elements
ctest
contact-list
connect-by
holder.js
bgp
php-parse-error
uid
pervasive-sql
reactive-banana
teamcity-8.0
fouc
ionic
responsive-images
processmodel
device-orientation
umbraco6
kineticjs
dia
coldbox
tt-news
client-side-templating
flask-cors
doskey
terminal-services
dataservice
django-nonrel
yui-compressor
plasma
orchardcms-1.7
spring-validator
ember-app-kit
simba
cascalog
windows-phone-7.1.1
gnustep
blackberry-playbook
invite
xtype
winbugs14
.nettiers
putchar

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App