1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question App dosen't work without USB-Cable

Discussion in 'Android Questions' started by alexOdysseus, Jul 2, 2019.

  1. alexOdysseus

    alexOdysseus Member Licensed User

    Ich weiß nicht mehr weiter. Das Programm läuft fehlerfrei im Debug/Release Modus. Doch sobald ich das USB-Kabel entferne, funktioniert es nicht mehr. Mir geht es hier um einen Veranstaltungskalender der statisch an zwei Tagen Benachrichtigungen senden soll. Getestet an einem Samsung S7 Android 8.0.0, B4A 8.80

    I do not know how to continue. The program runs error-free in debug / release mode. But as soon as I remove the USB cable, it does not work anymore. This is about a calendar of events that should statically send two days of notifications. Tested on a Samsung S7 Android 8.0.0, B4A 8.80

    Code Snip:
    Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
    Public PhoneWake As PhoneWakeState
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    Dim zeit As String
    Log("ich habe Samstag gestartet. Ich habe meinen Job gemacht und warte auf die naechste Zeit.")
    zeit = DateTime.Time(DateTime.Now)

    If zeit = "10:00" Then
    Dim n As Notification
    n.Icon = "icon"
    n.SetInfo("Nächster Event: eins","" , "")
    End If

    Dim tt As Long = FindNextTime(Array As Double(10, 10.08, 10.18, 10.25, 10.33, 10.42, 10.50, 10.58, 10.67, 10.75, 10.83, 10.92))

    Log($"Next Servicetime is: $Time{tt}"$)

    End Sub
  2. klaus

    klaus Expert Licensed User

    You need to compile the program in Release mode to make it independant.

  3. alexOdysseus

    alexOdysseus Member Licensed User

    As I wrote: it runs in both mode, but when I release the Cable, only the first event was shown:
  4. Erel

    Erel Administrator Staff Member Licensed User

    You should never use START_STICKY. It will not do anything useful and will cause problems on new versions of Android.
  5. alexOdysseus

    alexOdysseus Member Licensed User

    Thanks, I will try...
  6. alexOdysseus

    alexOdysseus Member Licensed User

    Curious, it works only if a cable is plugged, no USB debugging but charging mode.
  7. KMatle

    KMatle Expert Licensed User

    What exactly works or not? Do you get an exception or what happens?
  8. alexOdysseus

    alexOdysseus Member Licensed User

    OK, this should be an information app for a local Harley event. The user should be informed, when the next band is on the stage. And for this, a notification will be popup. In my test every 5 minutes. You can also tip on a row and a picture comes in front and you can resize it.
    With hyperlinks to several pages. Everything work fine, when a cable is pluged and so in charging mode, no matter if the display is on or not. But when I install the app and unplug the cable, only the first notification on the next timetable pops up and that's it. No error, nothing. You can view the pictures click on the lnks, everything works, but no notification.

    In my eample, I remove the pictures, because it's too big.

    Attached Files:

  9. Erel

    Erel Administrator Staff Member Licensed User

    Peter Simpson likes this.
  10. alexOdysseus

    alexOdysseus Member Licensed User

    Sorry, a lot of work, less testing, less time, but I never give up!!! Still wait for my response!
  11. alexOdysseus

    alexOdysseus Member Licensed User

    Now it works! I think the most reason for this is the line:
    that will bring the message in front.

    Thanks a lot!!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice