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 populate Google Sheets via API in Java
Any hint to simplify this POST? (Java)
Write a java program using Scanner to help you decide what to do this weekend
Java Reading large files into byte array chunk by chunk
How to set Abitrary Units properly?
Spring RestTemplate exchange DELETE with body jdk 1.8
Get response from request PHP in Android
How do I structure my Android Studio project to avoid compilation issues with running the app with unit tests integrated
Using AsyncTask with SQLite Database
Hibernate Many-to-Many self join with extra column
JAVA ISBN-10 Number: Find 10th digit [closed]
Cannot install .ipa file using Appium
Connect TableView columns to the HashMap values
Control headers from SSI-included JSP
opening a shared local folder(C drive or D Drive etc..) from a JSP deployed in a tomcat server
request.getParameter(“f”) evaluates to null

Categories

HOME
yii2
testng
single-sign-on
include
relayjs
rsync
sqlite-net-extensions
leon
jxls
win32gui
upload
qore
primary-key
modelica
nstableview
quickfix
systemc
finite-automata
lucene.net
nas
amazonsellercentral
object-detection
chromium-embedded
microsoft-sync-framework
facet
publish
ejabberd-module
libssl
vision
nouislider
r-raster
galsim
code-contracts
azure-sql-database
xmlreader
geopositioning
overlap
dosbox
git-merge
restlet
dartium
retina-display
hot-module-replacement
hockeyapp
gesture
dynamic-reports
elmah
http-live-streaming
android-mediaprojection
no-www
checkboxlist
segment
convertapi
upstart
jedis
return-value
dotnetzip
directory-structure
magma
lift-json
android-cursor
knpmenubundle
pdfclown
arrow-keys
titanium-android
angular-strap
probability-density
elements
adxstudio-portals
multi-level
python-stackless
design-by-contract
xpath-1.0
endeca-workbench
metaclass
sframe
fluid-dynamics
p2
csquery
tween
google-style-guide
android-nested-fragment
nsbutton
websocket4net
xceed-datagrid
oracle-warehouse-builder
blending
mylyn
android-screen-support
delphi-6
free-variable
bitsharp
isnullorempty
onsubmit
qtkit
work-stealing
custom-backend
genshi
psi
locationlistener
servicehost
datareader
remember-me
sudzc
dentrix
suppress
routedevent
web-architecture
pascal-fc





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