"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.
Related
I have just started android and I created an app that was running fine a few days ago now I am working on another app but I am not able to run that and now I’m not even able to run the previous one.
now it's just showing Waiting for all the target devices to come online
and then it says Gradle build finished in 830ms or like that!
now it's just showing Waiting for all the target devices to come
online
To solve this-
Go to Device Manager>> Virtual and select launch AVD or from options select cold boot now.
Like Zobaer says, if it says waiting for devices that usually means the build has completed (you can check that in the Build panel) and it's waiting for the emulator to show up. If your emulator is already running, try closing it and running the app again. Otherwise if it's not getting started, try starting it yourself.
I'm just posting an answer to point out that you sometimes do need to be online for Gradle to run, but you can put it in offline mode:
That button in the popout panel, or you can always do Ctrl+Shift+A as usual and start typing what you're looking for!
I just want to show an alert box at just killing the application in android.
It's like a Notepad application, if we simply kill the app (on clicking the close button) then we get an alert box asking for save changes.
I just want to add same thing in my application.I have tried onBackPressed() and its working fine on clicking on Back Button. But I need same thing on closing the application.
There is now way to be sure if the app is being closed but you can place a check if the application is in foreground or not which is a better metric IMHO as this tells you when the user moved away from your application.
To check the ProcessLifeCycleOwner this will help you find state of process. You can check this Github sample or this stackoverflow question in how to use it.
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
I started a project of a windows program that connects to an android phone and gives the user information
about it, so I want to display all of the popups that appere on the phone. to do this I need the app version of the program to catch them somehow and give me the name of the app that sent the popup and the popup's contant. is it possible?
it would be kind of security issue if any app could do that... you can try with AccessibilityService with some permissions for reading screen/running Activities and checking style of every Activity is this "popup", but note that some of them are just DialogFragments. So I doubt you can recognize "popups" this way in a reliable way. Look for AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED for more info
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.