Android Question Unfortunately 'App' has stopped - Manifest Modified

floatingpoint

Member
Licensed User
Longtime User
Hi,

I've got a working app that communicates via USB Accessory.
All good using default manifest except that the connect and disconnect of USB requires manual intervention.
I want the App to automatically start and recover from broken/ disconnected USB.

I've got control of the USB disconnect by implementing a receive packet watchdog timer which calls close and exits if no packets are received in a certain time.

What I am struggling with is the auto start-up of the app when the USB is connected to the identified host.

I have tried to understand manifest files and accessory_filter files and after some fiddling about with read only attributes, I'm pretty sure that the accessory_filter.xml file is OK:

B4X:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<usb-accessory manufacturer="Widgets Pty Ltd"
model="First Display"
version="1.0"
/>
</resources>

However, I'm unclear as to what is required and its syntax in the manifest:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-feature android:name="android.hardware.usb.accessory"/>
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>
    <application android:icon="@drawable/icon" android:label="Aqua Display">
        <activity android:name=".Chiller Display"
                  android:label="Aqua Display"
                  android:screenOrientation="landscape">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
                       
          <intent-filter>
              <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>
            </intent-filter>
       
            <meta-data
                android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
                android:resource="@xml/accessory_filter">
            </meta-data>

        </activity>

    </application>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

My source code starts with:

B4X:
Region Project Attributes
    #ApplicationLabel: Aqua Display
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
    #IncludeTitle: False
    #FullScreen: True
#End Region

Unfortunately the app never gets started, no log messages after "Installed" and an immediate error message "Unfortunately "Aqua Display" has stopped"

Any pointers to what is good/ bad about my manifest file would be greatly appreciated.

Thanks in advance.

FP
 
Last edited:

floatingpoint

Member
Licensed User
Longtime User
rbsoft said:


Thank you rbsoft and Erel.

I have success using this manifest:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>
<uses-feature android:name="android.hardware.usb.accessory"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
AddActivityText(main, <intent-filter>
        <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
    </intent-filter>
  <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
        android:resource="@xml/accessory_filter" />)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

This forum is very constructive and helpful.

When my knowledge of Android and B4A improves I hope to contribute.

FP
 
Upvote 0
Top