Android build in store behaves differently than apk installed via USB
Asked Answered
P

2

16

I'm having a very confusing issue. I have built a final release APK of my app, submitted it to the Play Store, and installed on my test device. The application has exhibits different launch mode behavior when I install it this way.

My generated APK is the product of a Gradle build going though both Proguard and zipalign. For ease of explanation, say my app is a dashboard type app whose main Activity shows a launch button for activity B. I took this release APK and installed it to my device via USB 'adb install ' so I'm comparing the exact same APK with two different methods of install.

USB Method: When a user clicks on the button in the main activity to launch Activity B, Activity B is launched and shows on screen. If the user hits the home button (gets a call etc) then comes back to the app, Activity B is still showing. This is the desired (AND EXPECTED) behavior.

Store Method: Downloading the APK from the store and installing/launching again shows the main Activity. When the button is clicked, Activity B is again launched. Now, when the user hits home and comes back, the back stack is apparently cleared and the main Activity is shown again.

I do not specify any special launch modes in the manifest so all activities are standard. How could the method of installation affect such a thing!? This is driving me mad. Does anyone have any idea of why this might be happening?

Practise answered 7/4, 2014 at 22:38 Comment(8)
Just a guess, but are you pushing a release or debug version with adb?Debarath
release version, same version I am uploading to Play sadly :/Practise
OK, have you made sure you are not restoring the application in one instance and not the other?Debarath
Other than this, I can't find anything saying the functionality of the apk is modified...Debarath
Yeah this is wacky. No, not restoring or doing anything different in one APK over the other. They are byte by byte identical. The only thing I can think of is to hack in a state machine that manually restores the correct Activity by relaunching but that is ridiculous.Practise
Have you tried without proguard?Burnedout
possible duplicate of How can I make an android app stop restarting every time it is opened?Numbat
@AndrewG I am facing the same issue have you find any workaround for that?Rillings
E
0

The difference is in app priority in the OS. Android will give the app installed from USB a higher priority than play store app, then when the system needs memory it will despose the low and normal priority apps and keeps high priority apps.

Of course this is different from device to another.

Ernst answered 13/8, 2022 at 13:19 Comment(0)
D
-1

I had the same problem and this worked for me. Explicitly set the launchMode in your Manifest's activity element.

android:launchMode="singleTop"

"If an instance of the activity already exists at the top of the target task, the system routes the intent to that instance through a call to its onNewIntent() method, rather than creating a new instance of the activity."

See the documentation for more options and an explanation: http://developer.android.com/guide/topics/manifest/activity-element.html

Dissymmetry answered 5/10, 2014 at 19:53 Comment(1)
I also facing the same issue to which activity I should apply this launch mode and what should I handle in new intent methodRillings

© 2022 - 2024 — McMap. All rights reserved.