Android Question Notification entering app

Scantech

Well-Known Member
Licensed User
Longtime 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.
 

Scantech

Well-Known Member
Licensed User
Longtime 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.

** Activity (dashboard) Pause, UserClosed = false ** 'Caused by Home button
Killing previous instance (main).
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
android.permission.WRITE_EXTERNAL_STORAGE true
android.permission.ACCESS_COARSE_LOCATION true
** Activity (main) Pause, UserClosed = true ** 'Caused by exiting app
No wakelock.
Sub mnuDisconnect
No wakelock.
Setting Manager Debug Log
*** Service (starter) Create ***
Using FileProvider? true
DKKD
DKJD
** Service (starter) Start **
** Activity (dashboard) Create, isFirst = true **
Panel size is unknown. Layout may not be loaded correctly.
-----------
-----------
Reusing DrawRoundedAnalogBackgroundandBorder
** Activity (dashboard) Resume **
ERROR ACTIVITY RESUME IN DASHBOARD
*** Service (comserial) Create ***
comserial_service_create (java line: 3025)
java.lang.NumberFormatException: empty String
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1071)
at java.lang.Double.parseDouble(Double.java:547)
at scantech.cardiagnosticpro.comserial._service_create(comserial.java:3025)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at scantech.cardiagnosticpro.comserial.onCreate(comserial.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:3162)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1550)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
This is what i was looking for

B4X:
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.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime 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?)
ERROR ACTIVITY RESUME IN DASHBOARD java.lang.RuntimeException: Object should first be initialized (AHViewPager).

I have this in Dashboard Activity Resume (Starter.atPage is int)
Pager.GotoPage(Starter.atPage, True)

and this is Dashboard Activity Create (8 panels are created)
Pager.Initialize2(Container, "Pager")

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:
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime 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:
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime 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

** Activity (dashboard) Pause, UserClosed = false **
Killing previous instance (main).
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
android.permission.WRITE_EXTERNAL_STORAGE true
android.permission.ACCESS_COARSE_LOCATION true
** Activity (main) Pause, UserClosed = true **
No wakelock.
Sub mnuDisconnect
No wakelock.
Setting Manager Debug Log
** Service (comserial) Destroy **
** Service (communicationroutine) Destroy **
No partial wakelock.
** Activity (dashboard) Resume **
*** Service (comserial) Create ***
** Service (comserial) Start **
*** Service (communicationroutine) Create ***
** Service (communicationroutine) Start **

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:
Upvote 0

Didier9

Well-Known Member
Licensed User
Longtime 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.
 
Upvote 0
Top