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

return before finally in java
Starting a second JavaFX Application
Newline character is not interpreted correctly in MimeMessage?
Sending an mail in java using smtp
Java GUI printing blank page
Does Java have an equivalent to C#'s XML attributes?
Set findbugs NotNull as default for all classes under a package
Save to binary file
Will getMessage for new message force a reload in Spring ReloadableResourceBundleMessageSource?
JSP, “User cannot be resolved to a type”
Limit the size of a collection in JPA
How to draw a waveform for 2 or more channels:Getting amplitude from 2 or more channels?
Hard limit/upper bound on number of keys in HashMap java [duplicate]
How should i model the training set in my neural network?
Accessing a Java Swing GUI from another class
Finding a file path in java gui using File

Categories

HOME
magnific-popup
plot
syntax
vmware
yahoo-oauth
tizen-web-app
youtube-api-v3
binary-tree
sql-server-2016
fancybox
azure-storage-tables
upload
synchronization
midi
izpack
alignment
task
hex-editors
ibm-odm
quickfix
clearcase-ucm
libtiff
angular-ui
captiveportal
microsoft-r
jndi
blazemeter
smb
one-to-many
buildbot
javacv
linkerd
fluentvalidation
compatibility
tasklet
google-rich-snippets
key-value-observing
titanium-mobile
avcapturesession
asset-pipeline
environment-modules
g-code
errordocument
dandelion
integrity
magma
sybase-asa
lync-client-sdk
color-profile
synchronous
eventkit
visual-c++-2008
login-control
fuzzy-search
multiple-regression
bluemix-app-scan
tform
system.management
quicklisp
security-testing
wyam
map-projections
service-accounts
sysinternals
bridge.net
facebook-graph-api-v2.4
article
heisenbug
expected-exception
valuechangelistener
oracle-warehouse-builder
viadeo
openlaszlo
uv-mapping
geos
blending
sqlperformance
spring-validator
bitsharp
word-processor
venn-diagram
dsn
viewswitcher
php-parser
mercurial-server
calling-convention
disclosure
revisions
suppress
simpletest
sustainable-pace
project-hosting

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