android


Send message to custom service via adb


I create simple android application which contains one activity and service. The service is defined by aidl file and can receive calls from the activity via Binder. Everything works as expected.
Now I deploy the application on device (also I've tried an emulator) and I want to send message to the service via adb:
$ adb shell service call \
com.example.gluttton.dummyandroid/.DummyService 0 STR "Bingo!"
and got message that such service doesn't exist:
service: Service com.example.gluttton.dummyandroid/.DummyService does
not exist
I try to check is my service launched:
$ adb shell service list
or
$ adb shell service check com.example.gluttton.dummyandroid/.DummyService
and got similar result.
But at the same time I cat see my service using dumpsys:
$ adb shell dumpsys activity services Dummy
ACTIVITY MANAGER SERVICES (dumpsys activity services)
User 0 active services:
* ServiceRecord{a1627b5 u0 com.example.gluttton.dummyandroid/.DummyService}
intent={act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.gluttton.dummyandroid/.DummyService}
packageName=com.example.gluttton.dummyandroid
processName=com.example.gluttton.dummyandroid
baseDir=/data/app/com.example.gluttton.dummyandroid-1/base.apk
dataDir=/data/data/com.example.gluttton.dummyandroid
app=ProcessRecord{114da04c 20168:com.example.gluttton.dummyandroid/u0a126}
createTime=-21m40s817ms startingBgTimeout=--
lastActivity=-21m40s816ms restartTime=-21m40s816ms createdFromFg=true
startRequested=true delayedStop=false stopIfKilled=false callStart=true lastStartId=1
Also I can start my service:
$ adb shell am startservice com.example.gluttton.dummyandroid/.DummyService
Starting service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.gluttton.dummyandroid/.DummyService }
and stop it:
$ adb shell am stopservice com.example.gluttton.dummyandroid/.DummyService
Stopping service: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.gluttton.dummyandroid/.DummyService }
Service stopped
So my question is where is my mistake and how to send message to my service via adb?
I think system/bin/service is only for working with android system services. If you do a adb -s emulator-5554 shell service list for example you will see only a list of services such as
Found 100 services:
0 carrier_config: [com.android.internal.telephony.ICarrierConfigLoader]
1 phone: [com.android.internal.telephony.ITelephony]
2 isms: [com.android.internal.telephony.ISms]
3 iphonesubinfo: [com.android.internal.telephony.IPhoneSubInfo]
If you wish to send a message to your service you can do so via
adb shell am startservice [options] intent
Start the Service specified by intent.
See the Specification for intent arguments.
Options are:
--user user_id | current: Specify which user to run as; if not specified, then run as the current user.
see this link for how to set up the intent as an argument

Related Links

Android NullPointerException while retrieveing data
How to get the intent filter of an android app
Classes to test aren't within scope of test package
Can I use Linux system calls in android?
Devices Layout [Android]
URLClassLoader working on Java but not in Android
How to know if the application is in foreground?
Android class diagram and XML
Prestashop and web service(Restful), HttpURLConnection, BufferedReader
Assign text read from file in network to TextView in Android fragment
How to execute TranslateAnimation sequentially without knowing how many translate you'll have to do (android)?
Android MediaCodec issue on Alcatel OneTouch 7025D
FATAL EXCEPTION: java.lang.RuntimeException: takePicture failed
Detect if Google Plays services is installed from a browser
Android Read WhatsApp Data
Which is best for an android app: Using bitmap or drawing the circle?

Categories

HOME
amp-html
ns-3
mjml
jmx
grafana
pdfbox
gson
alamofire
selenium-ide
http-post
linear-algebra
dynamic-sql
user-experience
undertow
imagemap
dpdk
backpack-for-laravel
question2answer
r-mice
ios10.2
easeljs
pchart
fable-f#
licensing
openmdao
bioinformatics
gp
sqlpackage
livelink
complex-numbers
mockjax
laravel-eloquent
hard-drive
gojs
joomla2.5
navigator
searchkit
nohup
projects-and-solutions
gdata
mongoose-schema
naming
signal-strength
httr
double-click
posixct
amq
context-switch
tinkerpop
java-6
opengl-4
jqchart
pdf-conversion
cmp
vibrate
vcloud-director-rest-api
preprocessor
nikeplus-api
dimension
xdoclet
lean
kango-framework
bizagi
assertion
dynatree
django-urls
page.js
coda
rdflib
jsvc
dot.js
openbabel
cryptographichashfunction
nodelist
primitive-types
psr-4
jjaql
gtm-oauth2
mysql-error-1044
nevron
ui-select2
wp7test
twisted.web
android-sdk-2.3
sqlclr
fragmenttransaction
paginator
cgimage
silent
opml
great-circle

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