I have a requirement to integrate an android application with the ADB Daemon in order to pass commands to it (my Android application) through the USB interface.
Is this possible ?
My intention, is to plug this Android device to a Linux device and allow the Linux device to pass commands to the Android application via USB.
Therefore, since ADB is already implemented, and the ADB drivers for Linux also exist, I was wondering whether it would be easier to leverage this to allow the kind of communication I require.
You can use Activity Manager through adb shell.
For example, "adb shell am broadcast " will send broadcast intent to attached device.
Then your app can handle it with broadcast receiver.
Related
I have a third party application in my android phone.
The application offers a service at 127.0.0.1:30002.
I don't know the name of service.
Is there a way to find out whether that tcp service is up or not using adb or some other means.
Also what is the use of adb reverse.
Can i run a server in host pc and forward that server on android using adb reverse.
I am completely new to android, so please be brief.
Thanks in advance.
To find which app using specific port:
1. $ cat /proc/net/tcp - This will give you a list of open ports and the UId (unique application ID) of the port's owner.
2. & cat /data/system/packages.list | grep '<The UID you just found>' - This will give you the app name connected to this UID.
3. ps |grep '<the app name>' Will tell you if the app service is running.
What is adb reverse?
adb reverse tells your phone use a port of your local machine (e.g laptop).
Assume you use the command:
adb reverse tcp:80 tcp:3000
Now when your phone tries to access http://localhost:3000/ your request will be routed to localhost:80 of your laptop.
Is it possible to simulate or mimic a call coming in on an Android device programmatically from the device (not connected to a computer)? I am doing a safety demo about the dangers of calls while driving and I would prefer not to have to create my own copy of the call app.
Yes you can!
Use adb for that, for emulators you can also use the android-studio tools.
adb -s <serial> shell am start -a android.intent.action.CALL -d tel:0612345678
Where <serial> should be your device or emulator id (like emulator-5555)
If you want to do it on the device itself, you can try to call yourself (yes it kind of works on most devices).
Could anyone tell me is it possible to test an android application that connects two phones using wifi(or any network connection) with the help of two Emulator instances.
We would like to make an social networking app that uses location services in android.But since I don't have an android phone I would like to know whether we could test the application using two Emulator instances.
Of cause you can connect to devices as many as you have. First you can connect to your phones via USB and run "adb tcpip" to set all the device to restart ADBD on network interface. The you can do "adb connect IpAddressOfEveryDevice". To direct command to specific device, use adb -s IP:PORT command
I want to simulate a Bluetooth headset being connected to a phone, to see how my code reacts to the intents and the connection as a whole. I'm testing on a real device connected via USB, in Eclipse.
I have been able to simulate the pressing of a "media button" by running the following:
adb shell input keyevent <keycode>
I was hoping for something similar, where I can set the device name, device class etc and trigger it?
Running the following produces instructions on various calls that can be made to adb:
adb shell am start
The way to trigger an intent "ACL_CONNECTED" is by typing this:
adb shell am broadcast -a android.bluetooth.adapter.action.ACL_CONNECTED
further options can be added in the command, as per the instructions from above.
The problem is, I want to simulate all the functionality of a Bluetooth device, not just the few intents it triggers. In other words, I want a dummy Bluetooth device which is indistinguishable from a real device from the phone's point of view.
Is it possible to invoke "bu" (backup) service directly from android app or native shell on non-rooted phone? I know it is possible to do it via "adb shell backup". However, the main requirement is to be able to initialise this request without any prior usb connection.