Android Question Phone won't restart with b4a app installed

qsrtech

Active Member
Licensed User
Longtime User
Hi, I've updated my note 2 to 4.3 and it won't boot with one of my specific apps installed. Other (samsung) devices <4.3 seem to boot OK. Phone needs to be factory reset to boot again.

Only seems to happen after actually opening the app. I.e. It can be installed and will reboot successfully. It uses text writer/reader, http service and sql lite extensively among other things. It is well over 20k lines of code with tons of modules.

any ideas?
 
Last edited:

qsrtech

Active Member
Licensed User
Longtime User
don't get any logs when rebooting but I think I found the culprit in my manifest:
AddReceiverText(usbconnectedservice,
<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 is my service code
B4X:
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub
Sub Service_Create
    Log("USBConnectedService Created")
End Sub

Sub Service_Start (StartingIntent As Intent)
    'notify our print service that our usb must have been re-connected
    Log(StartingIntent.Action)
    If StartingIntent.Action="android.hardware.usb.action.USB_DEVICE_ATTACHED" Then
        'how to check if service is started?
        Try
            'launch our print service app
            If PrintService.JobList.IsInitialized Then
                If PrintService.JobList.Size>0 Then
                    'try to reconnect and print
                    'CallSub(PrintService,"doPrintJob")
                    Select Case Globals.PrintMode
                        Case Globals.PrintModeUSB
                            CallSub(PrintService,"ConnectUSBPrinter")
                    End Select
                End If
            End If
        Catch
        End Try
    End If
End Sub

Sub Service_Destroy
    Log("USBConnectedService Destroyed")

End Sub

any idea why?
 
Last edited:
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
device reboots properly now that I've removed the manifest text above. Before the device would just hang at the samsung logo. I don't use the service module anymore as I built a new independent app/service. I just left it in the project until I was ready to clean it up. It's just weird how it (AddReceiverText) prevented the phone from booting up in 4.3.
 
Upvote 0

boten

Active Member
Licensed User
Longtime User
....
You should never have an empty Catch block. You should at least add Log(LastException).
A side note, why? What if I want to perform an action that "might cause an error" but the error is not crucial to the app.
for example: trying to direct the user to google play, suppose his internet connection is off, then just continue without showing google play.
What is so wrong with having an empty catch block? (of course the catch block can be trivial like A=1)
 
Upvote 0
Top