How to trigger an android app on the phone using the laptop? - android

I have an application on my G1 Android Dev phone(android 1.5). I need to trigger this application automatically from my laptop. The system will not be deployed in an area where there is WiFi, so I cannot send a packet to a service on the phone which will be listening for a particular packet from the laptop and then call an intent to launch my application. Is there any way in which I can send out a packet using the USB cable to a service running on the phone? Are there APIs available for this?

You may be able to invoke the launch app intent via adb shell, the start command, and the application's launch intent. It looks like this person got it to work. This may require rooting a physical device.
Edit:
Another idea: launch the app with the UI Excerciser monkey, but specify 0 for the event count.

Related

Can I launch a specific app when android device get physically connected to a specific usb device?

Can I "register" a (already installed) specific app to be launched when android device get physically connected to a specific usb device ?
Eg.
I connect a keyboard (of a certain brand or with a special USBid/class) and it automatically launch a text editor app
I connect an USB soundcard and it launches an audio app.
And "better", is there an autolaunch on Android ? I plug a keyboard+storage device to my smartphone and Android will ask me if I want to install the apk from the storage (or download it from predefined url)
Obviously for security reasons I understand installing the app from the storage will need confirmation by user. But, once the app has been "registered" would it be possible to launch the app automatically without having a confirmation screen ?
I know I could get USB info with android.hardware.usb.usbdevice. My question is more about how I can tell Android to launch this app rather than another when usb device is connected.
I think you could register your app to receive a system broadcast like USB_ACCESSORY_ATTACHED and make the logic to launch your app when this happens.
Check https://developer.android.com/guide/components/broadcasts
https://developer.android.com/reference/android/hardware/usb/UsbManager.html#ACTION_USB_DEVICE_ATTACHED

Autorun application when phone connected to pc

Is there a way to open an application from dekstop pc (such as an autorun) when the Android device is connected to pc?
Say that I have been creating an Android Application, and then the application is installed in my Android device (phone / tablet). And I want to give this application a special authority that will let the device to run the app automatically when the device is connected to pc.
Actually, the command that will be run by this app is only a command to open a web browser.
My question is:
How to give this application a special authority that will let the device to run the app automatically when the device is connected to pc?
Can someone give me a lighten?
Many thanks in advance!
You can register broadcast receiver that will wait for example for battery change state broadcast (see this: http://developer.android.com/training/monitoring-device-state/battery-monitoring.html). When such broadcast is received, determine if you are connected to PC and start proper activity.
I guess that you might need your application to work all time (have started sticky service) to make this work.

Android local voice service

As we all know, you can use an Android phone to dial a number to make a phone call.
Is there any way using the Android SDK to dial a number, but connected to a service running locally on the device?
My aim is to create some sort of interactive voice service (running locally on the phone), that could be used with bluetooth device that only support making phone calls...
My back up plan would be to run an Asterisk server in the house to handle this, but it would be nice to have something running on the phone instead.
Thanks

Send SMS through ADB to phone

I want to send test SMS messages from my PC via adb, to the phone. Is this possible? I've seen scripts to automate sending SMS from the phone, but I want to simulate SMS messages to the phone. I was able to do this via the emulator by telneting to it. Is there something I can do with a real phone (Galaxy Nexus). I do'nt have the development phone hooked up to phone service; I want this to be directly from the comptuer to the phone.
You could develop a small application that receives an Intent and which is capable of sending an SMS accordingly to the received data.
You need to declare a custom <intent-filer> in your AndroidManifest.xml and bind a BroadcastReceiver on that Intent. So you will be advertised everytime an Application issues this Intent.
On the other side, use the command line to send intents to your VMs using :
adb shell am start -a broadcast com.messenger.sms.send -e message my_message
In the BroadcastReceiver, the extra data will be accessible through a call to :
intent.getExtras().getString("message");
You can also find here more thorough examples on what you can do using am.
Do you have another cell phone with actual service?
If only a rough simulation is what you're looking for, I'd suggest you set up a Google Voice account to receive texts from a Google Voice number via wifi, or just use something like MightyText to synchronize the sms messages/notifications from your activated phone with your deactivated development phone (over wifi).
I assume that MightyText will probably be the easiest and quickest to set up between the two.

capturing another activity's screen in android

is it possible to have a service (A) which will launch an activity (B) and then periodically capture B's screen?
also, is it possible to send onTouch events from A to B?
basically, i'd like to make a bot which would use an application so i don't have to.
i guess it's not possible but had to ask.
You can't do that across Activitys but you could create a view that held the Activity that you want to automate. Then periodically you can grab the ViewDecorator and do some processing on it and then inject touch events.
Screen captures of apps which are not the current app are prevented in Android devices due to security considerations.
As far as I know up until Android 4.3 you can only do this in these scenarios:
Your device is rooted
Your app is signed with the same signature of the system (Google apps)
With adb (debug environment): your device is connected via USB to a PC which is running adb shell commands, or either the USB is disconnected but you have started the native adb service in your device after each device reboot.
Some useful links:
How to programmatically take a screenshot in Android?
How to make a capture screen app on Android
http://code.google.com/p/android-screenshot-library/wiki/UserGuide

Categories

Resources