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

How to run powershell script from remote machine with Java?
ComboBoxViewerCellEditor and AutoCompleteField doesn't work
Add icon to a (link) element / element in element
Suppress Keyword Expansion in Shell Script
Mongo match in aggregate not working for date using java
Java method arguments of two types
Neo4j queries slows down but after restart are fast again
Execute linux command in java and display output to html table
Java Annotations javaArgs and LiteralArguments are deprecated
NoSuchMethodError while parsing xsd to generate classes using JAXB
Hibernate using sql call for each row to fetch relationship - instead of aggregating to one IN clause
How do I make a local variable increase consistently in a recursive function having more than one calls?
Intellij IDEA : Spark code running results in java.lang.VerifyError
JavaParser comparison
How To use setOnItemClickListner multiple times in a ListView?
NullPointer exception in a Spring Rest Controller test - Java

Categories

HOME
webpack
plone
smarty
plot
homebrew
octobercms
umd
ckeditor
onelogin
convolution
indesign
uber-api
session-variables
spring-kafka
google-cloud-spanner
apache-cayenne
n-gram
apache-metamodel
contextmenu
immutable.js
xlsxwriter
one-hot-encoding
google-search-api
restful-authentication
fish
spark-jobserver
fluentvalidation
c++-amp
iframe-resizer
create-table
avcapturesession
wallpaper
nssegmentedcontrol
appfabric
automake
ws-security
optix
mime
celery-task
winscp-net
slickedit
google-perftools
hittest
bind9
dynamics-sl
dwscript
query-performance
background-service
google-cdn
deadbolt-2
sts-springsourcetoolsuite
phishing
ctest
wapiti
execute
msys
tarjans-algorithm
cakephp-3.1
graph-drawing
mono-embedding
nsight
web-controls
fscommand
gwidgets
clicktag
wp-query
mysql-error-1062
ccss
google-cloud-save
ocunit
distutils
broken-links
dsn
multipage
armcc
onsubmit
regsvr32
wse3.0
subgurim-maps
blackberry-playbook
coredump
xtype
javax.script
datareader
sproutcore-2
user-friendly
compiler-specific
web-architecture
iweb
backcolor
thread-local-storage
ubuntu-9.04

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