Regarding improper functionality of emulator in android studio - android

i am new here, but i checked the site, it does not contain my question, hence not duplicate. Actually, in my android studio v 1.1.0, emulator does not launch default activity automatically when started in android studio. What i mean is that when i click the green (play) button to run my project, my emulator is launched. When it loads and is ready to be unlocked, after unlocking my default activity should run automatically but it does not. Just The Home screen is shown no matter how much i keep waiting. No error reported in LogCat, neither any exception or anything wrong with code. So to run, I have to right click on my activity and click run MainActivity from the available options. So, how do i make the emulator automatically launch my default activity?

Related

Android studio: Error: Activity not started, unknown error code 5

Currently developing an Android app for my company.
Everything was fine, till my last debugging session on my test-device (tablet attached to android via adb).
When I try to run or debug my app, the "Run App" log simply shows:
Error: Activity not started, unknown error code 5
There is no further information, no stack trace, no nothing...
I tried to figure out, what I changed since the last time, but nothing seems to fix this.
Has anybody else had this error code 5 before and can help me?
Long story short: Unknown error 5 means (at least in my case), there is a lock (meaning a pinned app) on the device, so no other app can be started.
After a bunch of things I tried, I finally figured this out.
My app uses startLockTask() to pin it (so you can't accidentally press one of the navigation buttons).
The problem was, that this lock seemed to be active, even though the app wasn't running. I only realized that, after I tried to push the home button on my tablet (it already showed the android home screen, so it didn't occur to me, to try that...).
Once I released the lock (pressing both Back and Overview at the same time), I could start the debugging again, with no problem.
Restarting the device fixed the problem

How to stop android studio from running

How to I stop my code from running in Android Studio? I have tried selecting the program under the Java folder, but the "Terminate Application" button is grayed out. It's really annoying how the long is going crazy even though I have ended the app on my phone...
Here is a screenshot of my screen if it helps:
If you are referring to the lines in the logcat that keep appearing even when you app is stopped, this is normal, your phone keeps running other apps and logging status messages.
To suppress this output try selecting you application in the drop down menu on the right to show only your app's output
From this answer:
You need to select the process com.mycompany.myfirstapp and then press the Terminate Application button.

AVD Manager window blocks Eclipse window on Mac

I'm a complete newbie trying to learn how to write an app. I'm trying to run Hello World using the emulator in Eclipse on my Mac. I launch and unlock the emulator. Android Training then implies that I should click the Run icon in Eclipse. But the ADT Manager window is in front of the Eclipse window and Eclipse is disabled. If I minimize the ADT Manager window it just quits the ADT Manager, and then I must close the emulator window.
I did discover that I can run the app with the Run button without starting the emulator as a separate step, although that takes a long time to get going.
Another Answer implies that I can just rerun the app by clicking the run button again, but I can't do this because the Eclipse window is disabled.
I'm used to being able to use the IDE while a program (Yes, I'm an old programmer) is running. What am I missing?
Duncan
You're right - simply hitting run on the application cold turkey takes forever because the emulator has to initialize. When you click on your AVD Manager (where you can create, edit, and customize the android emulator you'd like to use), Select the emulator you'd like, then click Start.
After waiting for the emulator window to popup, just wait until the UI loads (when you can unlock the emulator).
At this point, it appears that the AVD Manager is still necessary (due to the "loading" type green bar along the bottom seemingly feeding the emulator), but you can just close the window, and the Eclipse window will become clickable again.
Now, you can just leave the emulator running. I typically leave it running for hours at a time (even overnight) and I can usually just click Run as Android Application and everything works perfectly.

Android application icon click different behavior

I've faced the different behavior of my app while clicking its icon if it was already launched before.
If I install the app via Eclipse or apk manager, launch it, press home button and then launch the app again clicking the application icon - it will bring the first activity from stack to front.
If I install the same version from the Play Market and follow the same steps - the application is relaunched completely from the very beginning (splash screen activity).
Is there a difference between intents which are used to start the app in this two cases?
How can I simulate the Play Market behavior to ensure that everything is fine before the release?
Thanks in advance.
This sounds like its to do with the android lifecycle. Read more here:
http://developer.android.com/training/basics/activity-lifecycle/index.html
Your activity will go through different stages when it starts back up depending on if it has been completely destroyed or if it has just been stopped. Pressing the home button will only stop your app rather than completely destroying it. If you're phone is running out of resources android might destroy your app in order to free up the resources its using.
Running from eclipse will start your app from a brand new start up (The same as people will get when they install from the market). So if it works when you run it from eclipse. It should work when other people install it too.

Application restarting after installing from SDCard and putting it on Background

I've created a sample application (just a textview, nothing else), and I noticed a bug.
After installing it from the SDCard, it displays the "Application installed" screen, with the done and open buttons.
If I click the open button, a strange thing occurs:
Whenever I put the application in background and reopen it from the application icon, it doesn't reopen it, it creates a new instance.
I can confirm that it is creating a new instance, because after putting it on background and reopening a few times, when I click the back button, it opens the previous instance, instead of returning to the home screen.
Now the strange thing is that it only happens after installing from the SDCard and clicking on the open button.
If I click the done button (or installing via ADB) and open the application via icon, it doesn't happen.
Also, if I click the open button (and the bug occurs), after the application is ended for the first time, the bug doesn't occurs anymore.
I've tested it in different devices and in different Android versions (GB, HC and ICS), and the bug is reproducing in them all.
Does someone know if this is an known issue from Android and if so, does someone have an official reference that I can refer?
Thanks in advance
Yep, it is a nasty, well-known Android bug that has been around since the very beginning. See the following:
Android issue 26658
Android issue 2373
Android app acts differently installed from adb vs sdcard

Categories

Resources