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

Android - retrieve value from XML using XPath
switch onClick buttons
How to use MultithreadedMapper class in Hadoop Mapreduce?
Java Error:WELD-000072 Managed bean declaring a passivating scope must be passivation capable
Distance Coding (DC) BWT
Java KeyListener: How to perform an action when two keys are pressed?
How to manage Heap Space in Java
How do I substract two XmlGregorianCalendar to create one Duration object?
Guice inject injector or generic provider somehow
flash socket not reading from Java Server properly
Android String contains two values
CXF JAXRS - How to POST more than one parameter
Layouting custom buttons
How to take portlet preferences correctly in Liferay?
java - detect action performed on JPanel in JDialog
Java Concurrency issues when updating video control UI while JMF video is playing

Categories

HOME
openmp
cookies
keras
reflection
c#-4.0
drivers
react-virtualized
vmware
bpmn
qore
esper
ssl-client-authentication
dax
leiningen
try-catch
pythonanywhere
flux
openedx
crystal-reports-2008
visual-composer
swingx
predix
kryo
scriptcs
tokenize
extjs5
core-text
bootstrap-tour
p-value
vlsi
react-css-modules
fifo
neo4j-spatial
yadcf
xquery-3.0
vsts-build-task
android-nestedscrollview
fusionpbx
android-ble
appfabric
space-complexity
sharefile
unspecified
vapor
upstart
komodoedit
qsslsocket
dds
python-c-api
paxos
lowpass-filter
mplayer
lift-json
crypt
arrow-keys
gcsfuse
topbeat
specrun
word-vba-mac
azure-virtual-network
url-masking
database-optimization
merge-conflict-resolution
paypal-express
clang-static-analyzer
nsviewcontroller
hill-climbing
sdf
pagerank
php-internals
reactive-banana
metaclass
sortedlist
jsapi
lustre
bigbluebutton
camanjs
codeigniter-url
preferences
reactfx
ms-project-server-2010
jmapviewer
html4
eventlistener
dmoz
hamiltonian-cycle
dsn
viewswitcher
work-stealing
transactionscope
nsobject
gcj
xmemcached
xdomainrequest
dmx512
icanhaz.js
memory-size
django-notification
uiq3

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