Android Question USB Serial Auto Start Problem

Kurt.McCullum

Member
Licensed User
I have an application that uses a USB to serial converter. It consists of a main form and two services. The main form fires one of the two services based on two buttons. I put the following code in my manifest so that whenever the USB to serial converted is attached, the application is started.
B4X:
AddActivityText(main, <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
    </intent-filter>
    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
        android:resource="@xml/device_filter" />)

This works perfectly. I plug in the USB converter and the application starts with the main form on the screen.

However, I have a problem when I reboot the device (An Android TV box). When the device boots with the USB to Serial converter attached, it auto starts both services but not the main form. This is troublesome because The main form is really what needs to be started and then it can start whatever services based on the user interaction (Or saved settings which will fire the service of choice).

What should I be tweaking so that when the device reboots, it starts the main form but not the two services?

Kurt
 

Kurt.McCullum

Member
Licensed User
Thanks Erel,

My code works fine as long as the unit is booted before I plug in the device. But when it's connected during boot, the activity doesn't get fired. Or it's being killed before I can ever see it. I'll have to create a log of some kind to trace this since it happens during the boot process.

Kurt
 
Upvote 0
Top