Android Question [ Solved ] AppUpdating - Ver: 2.05

Harris

Expert
Licensed User
Longtime User
Everything is working fine right up to the point AFTER app has been installed...


B4X:
after
Webserver's info file content:
ver=1.55
    Web version number: 1.55
    Current Version: 1.54
    Newer version available. Now I try its downloading
    -- TryApkUpdate
Donload ok? true
Copy2 (saving) ok? TRUE
    new apk version downloaded and ready to install - mhw
    user asked to install new apk 22  ' last line in debug....

This sub doesn't get called to Start the paused Main Activity... after the new app is installed (updated)...

B4X:
Sub MyAppReload
    If svcVerbose Then Log("-- AppUpdating.NewInst2: processing MyAppReload")
    If IsPaused( Main ) Then
        StartActivity(Main)
    End If


End Sub
B4X:

If one looks at Apps running (using button on device), one see's the "install app" screen still present. If you select it, the updated app comes to forground and works just fine...

What the hay?

Thanks
Harris
 

Sagenut

Expert
Licensed User
Longtime User
Upvote 0

Harris

Expert
Licensed User
Longtime User
B4X:
Sub Service_Start (StartingIntent As Intent)
    LogColor("---- AppUpdating.newinst2: service_started", LogColor1)
    LogColor("---- AppUpdating.newinst2: service_started", LogColor1)

    If svcVerbose Then
        Log($"${TAB}intent: ${StartingIntent}"$)
        Log($"${TAB}action: ${StartingIntent.Action}"$)
        Log($"${TAB}extra: ${StartingIntent.ExtrasToString}"$)
        Log($"${TAB}data: ${StartingIntent.GetData}"$)
    End If       
    If StartingIntent.Action = "android.intent.action.MY_PACKAGE_REPLACED" Then
        If svcVerbose Then Log($"${TAB}Intent MY_PACKAGE_REPLACED received!"$)
        pkg = GetPackageName
        If svcVerbose Then Log($"${TAB}package: ${pkg}"$)
        MyAppReload
    End If
End Sub
B4X:


My android ver is OS 9.

So, after the app has been updated (installed), would not the Service_Start be called and the Intent MY_PACKAGE_REPLACED received be seen to call MyAppReload?
None of the logs are seen, even if the StartActivity won't work from here (a service)...

Where do I put GetPermission method and when to call it after the app has been updated / installed?
Thx
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
I think you can request the permission when you want, even on app start.
But better to ask for it when an update begin.
When the user grant it then the request should not appear anymore.
But if the Subs are not firing maybe there is something else not working.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
But if the Subs are not firing maybe there is something else not working.
That's what I am thinking..... Without log statements showing up, they are getting called....
It is weird that the OS install form is in the background - and when brought forth and touched, it ends and the new updated app fires right up!
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Ok, everything is fine now.
After installing update, install form is dismissed and My App restarts as expected... Works GREAT! (as it has for the past 7 years!)

One thing of note is in newinst2, one needs to correct this....

B4X:
Sub MyAppReload
    If svcVerbose Then Log("-- AppUpdating.NewInst2: processing MyAppReload")
    If IsPaused( Main ) Then  '  was isPaused( "main") - incorrect - not a string but object
        StartActivity(Main)   ' same here - was StartActivity("main") - wrong...
    End If
    'Dim In As Intent
    'StartActivity(pkg&"/.main")
End Sub
B4X:


Thanks
Harris
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…