Android - different behaviour in release signed build? - java

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, login 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.

Related

My Android Studio emulator is not working correctly

I downloaded the Pixel emulator and Android API 25, but when running it
appears for a few seconds and then disappears
In the Event Log, this is what appears
I need help pls
The same Problem got me a few months ago:
I fixed it by doing this:
Whenever you run the project or app you have to clear the data of that AVD
To wipe the data of Emulator follow these steps-
Go To AVD Manager then you will see all emulators there then simply wipe data. ie- like in this image shown.
step 1
step 2
step 3
I also had random emulator crashes, everything would work for a short while, but then the emulator would just disappear as if it had stopped. The emulator.exe would still be running task manager, no way to recover the window and the .lock file couldn't be removed.
Even just starting the emulator and swiping the home screen left and right (not even starting my app), or going into the the apps drawer and back would cause the the emulator to stop working properly.
What worked for me was to always start Android Studio as "Run as administrator". So right click on the startmenu shortcut and select Run as administrator.
Not sure why it randomly stops working otherwise, I'm sure the Android Studio QA team thoroughly tests this on real-world laptops outside of Google labs right...? /s

Android app not minimizing as expected when clicking the home button

The Problem:
I have a React-native app, with a third party payment gateway sitting on top of it. My app needs launchMode in the manifest to be set like this:
android:launchMode="singleTask"
In the app itself, everything works as expected, but as soon as the third party payment activity is launched, an issue arises.
In this activity, if you minimize the app using the home button, and then launch the app again from the app drawer, the app restarts instead of resuming on the payment activity as expected.
However, if you set the launchMode in the manifest to :
android:launchMode="singleTop"
it works as expected i.e resumes the activity (with a caveat).
The caveat is that if the app launches via ADB or via the Play store (ie. not clicked from the app drawer) the same issue occurs. However, if you start the app from the app drawer, everything works as expected.
I need the launch mode to be single task though, and this bug is really puzzling me at the moment.
I was wondering if anyone has experienced this before and if someone could perhaps share some light on this issue. I unfortunately can't share too much of the code, but it's mostly standard stuff.

Android Studio Apply Changes asks if I want to Restart App

"Apply Changes" button was working with another project, but now when I click it I get a popup that says:
"Restart App? The app is already running. Would you like to kill it and restart the session?"
What causes it to want to restart instead of just applying changes?
Here you can find a detailed description of instant run:
https://developer.android.com/studio/run/index.html#instant-run
Normally all changes has to be compiled and republished to the device as new app. When your App is already running on the device this message is displayed. Android Studio has an Instant Run feature, when this is enabled the changes get applied without restart, but this didn't work every time.

Home button brings back to my app

I am making a car launcher application, which contains shortcuts to other apps, when i'm in another app i'd like to press the home button and go back to my launcher
So basically i need to override the home button outside of my app,the override has to work only when my app is opened in the background so when i close my app the home button will work as usual taking you to your default launcher
Can i implement something like this or i'm asking too much?
There is no way to intercept the home button on Android, unless you make your app the home screen. This is for security reasons, so that malicious apps cannot take over your device by overriding all the buttons that can exit. The home button is the one sure shot way to be able to leave any app.
In short, no it's not possible, and even if it were, it is a serious disruption in what a user expects out of an app's behavior.
If you go the route of making your app act be a replacement home screen you'll have to include in the install instructions for the users to set your app as the default launcher.
Then the home button would take them to your app. In order to get it to switch back to the default launcher when they are not in "car" mode would be a bit tricky but you could prolly achieve it with some sort of fork activity that checks if car mode is enabled if so go to your car mode launcher if not go to the default launcher (it gets trickier if the user already has a different 3rd party launcher) So essentially your app will always be the home screen app no matter if car mode is enabled or not, but if it is not then you manually start the "normal" home screen.

Restarting GAE in eclipse

So I am learning Google App Engine with Java. When modifying files i realized I dont always see my changes. I try clicking the red button to stop the web application in eclipse and then restarting the application however I dont see the changes. This even happens if i run chrome in incognito mode. I also have the same problem with IE and Firefox (By default i use firefox when developing due to my preference of firebug).
Also at times I will get annoyed with one project and start a new google app engine project. However the GAE will still be running the first one not the second one even though i close the project. Even worse was when i deleted the root project folder I still saw the index.html page though the links were broken for the project i deleted.
I am thinking there are two issues one is that my browser is storing these files in a cache. And the other is that I am not actually restarting the google app engine. Is the right procedure just to click the red square in the console in eclipse or is there something to run on the command line (in windows)?
To be brief , if i want to stop the GAE from in eclipse and restart it to see any changes i made whats the easiest way to do this on windows?
Thanks
edit:
Rumor has it that adding Google Web Toolkit to the project made my App Engine launch show up in the Development Mode pane, where it could be easily be killed or restarted. Is handling this issue this way a wise idea?
Trying out this touch command idea, i was hoping there was a command line way to restart the server similar to ruby on rails
the answer by dragon in this question would be helpful if it had more detail
The red button will stop it. You shouldn't need to run anything from the command line.
What you should do though is look at "Developement Mode" view and confirm nothing is running. It's under Window-->show view -->Other--> Google. Clicking on the gray arrows will show you what is open (running or not). Also, you can press the grey Xs to clear all stopped instances. This should confirm if something is running.
Also, look under run --> run configurations -->server. You have an option to set the port, or have it automatically set. If you are trying to run more than one project, your second one may not start if the first one has already taken the port. Keep that in mind.
As far as your browser storing Dev Mode page in cache, I don't think it can. In fact, if you close the running dev mode in instance your browser page should immediately update reflecting the fact that it has lost a connection. If it doesn't, surely you didn't manage to shut it down.
Ok, so I said the red button will stop it and it will, but you have to get the right red button. If you have more than one instance running, again look at the "Developement Mode" view, there is only one red button and you have to use the grey arrows I mention to get focus on the dev mode instance you want.
It's not really that complicated and you'll have it down by tommorrow!
Here is the Dev. Mode view. You can see I have three instances. The first is actually running, but shows red as there was an error. Clicking the grey grey Xs will get rid of the second two non-running instances and clicking the document icon with one grey x (it's not greyed out), will clear the log from the current running instance and remove the red x as there would then be no errors in the log.
Got it?

Categories