How should a android OTG usb device app work? - android

I do no get my android java app working the way i want it to work.
If i plugin the device i get a permissions dialog to start the app. The app is started and i can open de device.
If i start the app and plugin the device after the i started the app i am able to set the permissions, and i get a permissions dialog.
But when the app is closed and restarted the permissions dialog to not showing anymore.
Problem is that i cannot open the device anymore.
The only way i can get things working again is by unplugging and replugging the device.
So what i want is to show the permissions every time i launch the app.
Is this possible ?
Or can usb devices only be obtained once after plugin ?

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

Show USB permission dialog over Android Kiosk application?

So I have an application that is pinned to the device with startLockTask command and it has several restrictions so the user cannot escape from the application or change settings of the device.
However, the user should be able to transfer files from the device to a computer via USB, but when the device is connected to a "new" PC, the USB permission dialog: Allow access to device data is not shown because of the LockTask mode.
Is there any way to open that dialog in front of my application?
Faced the same problem today,
in my case I solved it by adding com.android.systemui package, while adding my whitelist application's in setLockTaskPackages DPM's method.
After this I can see the dialogue which was blocking up in LockTask mode.

Can't disconnect BLE devices when killing the app with background plugin on

I'm developing an app that interfaces with BLE devices using this plugin.
Inside the app, I can pair the devices and monitor their status.
If I close the app I want to disconnect the devices from the smartphone, and when I open it again, I want the app to reconnect automatically to known devices.
Everything works fine without using the background plugin, but I need to use it since the app needs to monitor the BLE devices even when it's in the background.
The problem happens ONLY if I use the background plugin: if I open again the app, the known devices are not reconnected INSIDE the app, but it appears they are already/still connected to the smartphone from the previous time (even if not shown in the Bluetooth devices in the phone settings).
It seems that the Bluetooth connection to known devices isn't really being closed when I kill the app.
It appears like the device is still connected as therefore it doesn't show up when I scan in the app.
I can't reconnect until I close the app, switch off and then on again Bluetooth, and reopen the app.
The steps are very simples:
I open and connect the first time from the phone to the BLE product
Communication is OK, data is sent and received
I close (kill) the application from the smartphone (Without turning off Bluetooth/BLE from smartphone)
I relaunch the application ---> Known device is not reconnected but appears to be somehow still paired with the phone (if I press the pairing button it does not go into pairing mode, that happens if it is already bonded to a phone).
Why this behavior? Looks like something in the background plugin prevents the Bluetooth connection to be closed on app closing. I specify that:
it only occurs using the background plugin, without it activated everything works ok
this behavior occurs only with Android (don't use the background plugin for iOS)
it does happen only on some Android smartphones: tried three different phones, with Android version v4.4, v5.1.1, and v6.0.1, and only two of them show this issue (android version 4.4 on S3 and 6.0.1 on S5 Neo).
Thanks

Prevent app to uninstall like system app android

We are developing one app that will be pre-installed on device manufacture time. seems like a bloatware app.
we want to prevent our app to uninstall by user like Contacts and other pre-installed app.
i searched a lot on google. but getting the same technique like using device rooting.
i also tried by using this app. but when i am clicking on any app to move to "System/apps", it gives me message
"/system/app mover has been granted superuser permission"
and then i am getting Error i.e
"Error: cp: applet not found"
with Ok Option.
So i tried by using "Es File Explorer" to move app from "data/app/" to "System/app/" its also moving app to "System/app" but when i am going through App Manager, it allow me to "Uninstall". but i want to disable "Uninstall button" like other pre-installed app act.
i tried the same method.
Rooted my device.
Moved my app from data/app/ to system/app/
set permission rw- r-- r-- and reboot.
Still i am able to uninstall my app. Can anyone please help me to fix this issue.

Debug application over internet using eclipse

I have the following problem:
My phones USB port is broken and I have no way of running app on the phone other than sending it over bluetooth and install it every time I make changes to the code. So every time I make changes, I gotta spend min+ to see them in action. I don't want to use emulator.
Is there a way I can make eclipse run my app on the phone over the internet when I build/run the app the same way it does over USB? Thanks!

Categories

Resources