开发者

Android - different behaviour in release signed build?

Having some really strange "bugs" with my Android application at the minute, it I run it from Eclipse it runs fine, pretty much perfect.

It contains a login screen that I can access and get to my main screen fine when running through Eclipse. When I press the home key and return to my application it returns to the last position (Activity) the application was in.

However when I release sign a build and deploy it on the device it has different behavior,after going through the login screen when I press home and then return to the application the login screen always appears.

Code is identical in both builds, only difference is one is signed with the default debug keystore while the other is signed with my own release keystore.

Has anyone come across this? Its really confusing!

EDIT: More info:

The application currently works like this:

Main activity is launched which then calls the login activity, l开发者_运维知识库ogin activity then moves to my app core activity.

I have also discovered that it appears to be on the first run after install that I have the issue, if I run the app, force close it and then run it again it then runs perfectly without any issue.

So it seems to be something really strange?


I know this is an old question, but this issue created me some headache and I'm posting the solution below in case of someone is having the same problem.

The "weird" activity flow is different between debug and release mode because of Intent's launch mode. When you're in debug, you press the "run" button in order to launch the Main Activity. When you're in release mode, you installed the app, then you press the "open" application button.

Once the Application is opened from different location, the Intent will change and will cause to reopen the app. On top of that (thanks to Android's architecture) if you had multiple activity flow, e.g: Splash -> Login -> Main -> etc. and you press "home" and reopen the application from a different location, the whole Activity flow is restarted, BUT the old activities will remain in the stack. For me, that's caused some problems because of some variable initialization within a Singleton.

In order to fix this, you can set different launch mode within AndroidManifest for your activities:

android:launchMode="singleTask"

also, you could try with singleInstance or singleTop. Each launch modes are having different behaviour.

You can replicate this issue if you have your Application published in Google Play Store. Navigate to your app within the Store and press the "Open" button. Once the app is launched, press the "home" button and go to your Menu screen and open your app from here. You will see that the app is recreated.


Can you configure Eclipse to use the same keystore?

I use an Ant script, which installs my 'debug' application with the same key used for my published versions, so I have not seen this issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜