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

Android Question Notification entering app

Discussion in 'Android Questions' started by Scantech, May 1, 2019.

  1. Scantech

    Scantech Well-Known Member Licensed User

    How do I setup my notification not to enter app when clicked.

    When I click home button and click notification it always enter main. When my last shown activity is not main then it will crash the app when I exit.
  2. Erel

    Erel Administrator Staff Member Licensed User

    Where is the error message?
  3. Scantech

    Scantech Well-Known Member Licensed User

    If i go to Activity Dashboard and click Home button, then i click system app Icon it goes where it is suppose to be in Dashboard. But the notification behaviour is different. It goes directly to Main and this will definitely cause some issues. I do call ApplicationExit with main.

    I want avoid this issue and not allow user to enter app with the click of notification.

  4. Scantech

    Scantech Well-Known Member Licensed User

    This is what i was looking for

    notification.SetInfo("OBD2 Status", Body, "")
    It was set to Main previously. Pass an empty string will not allow it to enter app.

    I guess my app can't function properly if its not returned back to where it is suppose to be.
  5. Erel

    Erel Administrator Staff Member Licensed User

    You are doing something incorrect. Your app should be able to handle such cases.

    Make sure to use the starter service to initialize everything that is needed for your app to run.
  6. Scantech

    Scantech Well-Known Member Licensed User

    There are 2 crashes the first one i don't understand and second in comserial i can understand that one.

    If you look in the above Quote "ERROR ACTIVITY RESUME IN DASHBOARD"

    It crashed because of this (Pager not initialized?)
    I have this in Dashboard Activity Resume (Starter.atPage is int)
    and this is Dashboard Activity Create (8 panels are created)
    By Exiting Dashboard Activity(Not UserClosed) using home button, entering Main Activity from Notification, User Exiting Main Activity will go to Dashboard Activity, where Dashboard was still active(Not UserClosed) by Home button and then it will Create Dashboard Activity (Why Create???) and Resume. I don't understand why it says Pager not initialized and why it Created Dashboard where it should of been Resume only? This is not a typical correct behavior? Is the Error because it created new instance and did not kill the old Dashboard instance?

    Also, why it killed Main Instance (See QUOTE above)?

    I don't think any of this is in the tutorial section. lol
    Last edited: May 2, 2019
  7. Scantech

    Scantech Well-Known Member Licensed User

    1. A different activity was started.
    2. The Home button was pressed
    3. A configuration changed event was raised (orientation changed for example).
    4. The Back button was pressed.

    In scenarios 1 and 2, the activity will be paused and for now kept in memory as it is expected to be reused later

    This should of applied to Main activity behavior but it is not. Previous Main instance got killed.
    Last edited: May 2, 2019
  8. Scantech

    Scantech Well-Known Member Licensed User

    Oh by the way, My Main UserClosed = true has ExitApplication. Maybe that explains why it created New Dashboard? But does not explain why Pager is not initialized.
  9. Scantech

    Scantech Well-Known Member Licensed User

    More testing with more results.

    This one is good.

    My app can handle it very well if i do not use ExitApplication in Main

    As you can see no errors.

    ExitApplication has a weird behavior which remain unanswered ...why the pager did not get initialized.

    You notice my Services did not get destroyed with ExitApplication called after StopService. I think i need to remove ExitApplication. It was used, because i had an issue with one of the device back 10 years ago where bluetooth gets hanged and could not reinitialized astream or something like that. I did workaround by using ExitApplication.
    Last edited: May 2, 2019
  10. Didier9

    Didier9 Active Member Licensed User

    Erel has in the past discouraged the use of ExitApplication. He said this:

    "The OS will treat your app as if it has crashed when you call ExitApplication. In some cases it will try to restart it automatically."

    Bottom line, it is not a reliable way to terminate an application.
  11. Scantech

    Scantech Well-Known Member Licensed User

    Yeah, i think i remembered that.
  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