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.
Related
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
My project involves having a factory standard (e.g. NOT rooted) Android phone connected to a PC by both bluetooth and wifi but the phone itself is not physically accessible (it's in a locked plastic box) and is not intended for use by a person.
Is there any way to have an android phone reboot itself by sending it some sort of command over bluetooth or wifi?
Yes but it is tricky.
There are multiple case-scenario but the only condition is that the Bluetooth or the Wi-Fi connexion is established and maintained by a third-party app and that you have access to the code of this specific app (or even better, you are the developper of this app).
First thing first : the app in question must be able to receive a command either by Bluetooth or Wi-Fi that ask for a reboot.
If you don't have access to the app code or there are no third-party app involved (meaning its the OS (Android) itself that manages the connexion) that won't work at all.
Now, onto the tricky part.
The simplest way would be that the device in question is rooted and your app can be granted super-user (root) permission.
In that case, once it receives the reboot command, it can perform the rebooting process as follow :
Runtime.getRuntime().exec(new String[]{"/system/bin/su","-c","reboot
now"});
or
Runtime.getRuntime().exec(new String[]{"/system/xbin/su","-c","reboot
now"});
Because it might depend on where the su binaries are located.
In any case it might not work on all device so you should try which method works on the device you will be using.
Now, if you don't have a rooted device and/or you cannot root the device in question, you might be able to do it if and only if you sign your application as a system application.
More details here : https://stackoverflow.com/a/4966542/3535408
I hope it helps !
Target:
Sending a file to connected peers. The connected peers should recieve the File without a preinstalled app.
Situation - Question:
I'm writing an app that opens WiFi-direct or a WiFi-Hotspot for other devices. The other devices connect to the device (Main-Device) where the App is installed on. Now the Main-Device should broadcast a file and every device connected to the Main-Device should get a notification, that it could receive a file. But, the other devices should not need an App to receive the file!
Is this possible? Cause all I found till now describes how you can send something from one to an other device if both installed the same app. Using sockets and one device becomes server and the other client.
Reason:
I try to create a game, which just is installed on a Main-Device. Other devices can join the game by connecting over WiFi, then they'll receive a HTML5-file from the Main-Device which they can open in their browser. As soon as they have the HTML5-file they'll be able to interact with the game on the Main-Device.
But I don't want to force everybody who likes to join the game to download the app. Another Point is, if this is possible, I don't need to rewrite the app for other systems. Cause every Smartphone/Tablet has a Browser.
But, the other devices should not need an App to receive the file! Is this possible?
No, it isn't.
I try to create a game, which just is installed on a Main-Device. Other devices can join the game by connecting over WiFi
That, is possible. What you need to do is build a captive portal.
Basically, all DNS names resolve to your server's IP address, and all traffic that would be routed elsewhere is not routed to the internet. How you do this depends on your network setup. There is a lot of software available. I've used Untangle before with decent results: https://www.untangle.com/store/captive-portal.html
I'm going to create a mobile phone charger, that is accessible in public (like in bars or restaurants). Now I'm looking for a method to show to my "clients" an information about the device (about the sponsor).
Is it possible to trigger opening a webpage, after connecting the mobile phone to a USB port? Or ask the user to install an app? The port can be in a PC (not a charge-only port). I've read about "universal accessories", which can do a lot, but it looks quite complicated to create a charging "accessory" only to display a web-page.
Has anyone an better idea? Any other actions (other than opening a web page / asking to install an app) are possible?
Open it on a PC? Probably. On Android not without installing an app to do that or using Tasker.
Read up on Intents and specifically how to listen for Intent.ACTION_BATTERY_CHANGED if you want to have people install an app in order to use the charger.
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.