Android Question Galaxy S8+ Restarts Activity By Itself

epsharp

Member
Licensed User
Longtime User
When I first compiled my program in Release mode, I immediately noticed that the Main activity restarted by itself without my program doing anything. I checked all Timers, SQL, etc and could find no reason. I then tried compiling a B4A Sample-Auto Scale and found the same problem. I then created a New B4A App that contained only the Log(datetime) statement; same thing. The only way around this seems to be, put a counter in the Starter service, add one to it on Activity Resume and display a Splash Screen until the second resume happens; unfortunately it takes 13 to 17 seconds.

My S8 runs Android 8.0, and this behavior does NOT happen in debug mode. On my Fusion5 - Android 6.0, it doesn't happen at all, either debug or release.

Can anyone offer an explanation?

Regards

Ed Sharp

My Large Complex Program
========================
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Resume: 12:58:12

** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Resume: 12:58:26

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Auto Scale Example
==================
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Resume: 12:52:53
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Resume: 12:53:13

/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

Program with only Log instruction
=================================
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Resume: 01:05:30
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Resume: 01:05:45
 

BillMeyer

Well-Known Member
Licensed User
Longtime User
Mr Sharp Sir,

Without the code one cannot offer much help.
Please try and include it by going to File-->Export as Zip

My gut feel here is that you have a permissions problem, but will only be able to say if we see your code.

Enjoy !!
 
Upvote 0

epsharp

Member
Licensed User
Longtime User
Thank you for your swift reply.

The code is a B4A Create New App, no layout, no code, nothing in Starter, nothing in Main, except Log(DateTime) in the Activity_Resume. The problem does NOT happen in Debug mode, only Release. It does NOT happen on Fusion5 & Android 6.0. It does NOT happen on a Samsung Tab A & Android 5.1. However, as per your request, I have attached the code.

Regards

Ed Sharp
 

Attachments

  • TestS8.zip
    6.6 KB · Views: 184
Upvote 0

Pendrush

Well-Known Member
Licensed User
Longtime User
Maybe some app on your phone get focus and then your app get focus again, but you maybe don't see that is happening.
I have Nexus 5 with (custom LinageOS rom) Android 8.1, without any app, just my dev apps and don't have any problems.
I'm using latest B4a.
 
Upvote 0

epsharp

Member
Licensed User
Longtime User
It only happens on the S8, not other phones. However would I find the App that's getting focus? Additionally, why doesn't it do it in Debug mode?
 
Last edited:
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
@epsharp

I downloaded your code and had a look at it.

Firstly my System
Win 10 64
B4A Beta#1 v8.3

Manifest:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="26"/>

Android jar: Android 27

Device:
Samsung Galaxy S8+, Android Version 8.0.0 (Patched 1 May 2018)
B4A-Bridge v2.51

The app runs perfectly on my S8+ "Out the Box", I then modified it to contain:

#BridgeLogger: True
and I put in a 30 second timer with: Log("Timer: " & DateTime.Date(DateTime.now))

and it works perfectly everytime with out a problem, in both debug and release mode.

My suggestion thus is to check that your system is up to date and then, if the fault persists, try and find the problem on your device.

Enjoy !!
 
Upvote 0

epsharp

Member
Licensed User
Longtime User
My thanks to everyone that helped with this.

I haven't tried mangojack's suggestion yet but I have solved the problem.

Yesterday afternoon, I put some log and message box statements in the program and also put a counter in the starter and had the program wait for the second resume. I then took my phone over to a friends house to show him the problem. Well, the Splash Screen fired up, the message "Waiting for Resume" showed up... and nothing! It never did the second resume.

I was using USB debugging and watching the log file on my laptop. No matter the program, the Activity Resume fired two times. Remove the USB cable, NO second resume.

Update: Before sending this, I DID try (mangojack) using B4A Bridge with Bridgelogger set to true and the TestS8 program (no instructions except Log(datetime) and the Activity_Resume fired four (4) times ????

Anyway, at least I know that after compiling under release, untether your phone.

Thanks again for your assistance.

Regards

Ed Sharp
 
Upvote 0
Top