android: activity shows as a black screen when debugger is connected - android

When debugger is connected, one of my activities in an Android app is displayed as a black screen. When I run the application without debugger, everything is working normally. If debugger is connected and then I disconnect it, black screen disappears and ui is displayed normally.
Any ideas why that might be?
I reproduced the problem on two phones. Restarting the phone, uninstalling app, cleaning the project didn't do anything for me.
EDIT: onCreate() in the black screen activity doesn't even get called.. though the startActivity(intent) for it gets called.

Its not like that...Usually when you debug the application it will be very slow when compared to the normal behavior. You might be performing any task in onCreate() method that takes a bit time to execute. Until that is done UI wont be display.
I suggest you to keep some debug breakpoints and analyse where it is taking much time...

This also happened to me. Black screen after calling start activity and the onCreate of the next activity is not reached.
What I did was remove all the breakpoints on the called activity and all is good.

Related

App run in background and open it again make device lag

I have some problems to my app and I don't have any idea to fix that.
I open my app and use it for a while, then I let my app run in background which means I don't close it and use my phone do other things.
But when I want to use my app again, I found that my phone becomes very lag. When I click background app button to show which app is running in background, my app jumps to screen very lag, and when I want to click it or want to close it, it will very lag too, which means maybe my app make my phone become lag.
This situation only happen when I want to open my app again or I want to slide out my app to close it. When my app is running in background and I do other things, my phone will not lag.
I don't konw what happend to my app, can anyone tell me how can I check my app,
and know what happened that I can fixed it, thank you!
Check in your application code that you have not put a heavy task on onResume() method. If possible try to take that execution in appropriate life cycle method.
Put a break point on method which is call when the application got visible and try to find out that if any function is not taking much time to execution.

How do you debug an Android app that crashes the device?

I'm currently having an issue with certain Samsung devices where starting an activity with an intro animation sometimes causes the whole device to crash.
The app essentially transitions from an Activity with a VideoView to another activity with a VideoView. The video of the activity that just started stutters in a loop for about 10 seconds before the whole device crashes and restarts.
It's not crashing the device all the time, but is limited to a couple Samsung devices from what I've tested.
I've looked at crash logs of the device which currently seem to be inconclusive from what I can see.
Important but relevant note, I am finishing the activity once starting the next.
You could try to attach the debugger manually through Android Studio if your process is alive long enough after the boot sequence.
Source:
https://developer.android.com/studio/debug/index.html
One more thing you could try is to put the 'wait for debugger' instruction in your code, using the Debug.waitForDebugger() method.
Source: https://developer.android.com/reference/android/os/Debug.html#waitForDebugger()
Other than that, you could put a lot of logs in your code, then fetch them using adb logcat > crash-log.txt command from your CMD/Terminal.

android onresume?

I have an app that works perfectly fine after tons of testing, but when I exit out of the app (hit home screen) and let it sit for a while and come back to the app, I just have a black screen. I have tried to reproduce this, but have been unable to, because it is only when I let the phone sit for a while...I have tried exiting out on each activity and even opening memory intensive apps on top of my app, then going back to my app, but it always works fine. Unless I wait a while with the screen turned off then come back...black screen. Any ideas? Im not overriding onresume or onstart, should I be?
I've never seen this issue before but here are some tips you could try:
Check your LogCat to see the results of what's happening after letting your phone sit for a while
Are you able to reproduce this on the emulator?
Just curious, what type of phone are you testing this on? What Android version are you using?

Is there a way to update the AVD after making changes without restarting it?

Like the title says, whenever I make any changes in the code I don't see the changes in the AVD. Is there a way to do this without closing the AVD and starting it again?
I'm using Eclipse.
Thanks!
I have noticed this behavior at times as well. In the ADB log it will state something like the activity is already started and has been brought to the front even though it was already on the screen. Not sure what the cause of this behavior is and it seems to happen randomly. I have dealt with this in the past by force stopping the app in the AVD or just uninstalling it. Sometimes pressing the home button on the AVD and then running the APP from eclipse seems to fix this.

Android app crashes on second run

I have been working on my app and it runs on the simulator fine. I loaded it into my phone and now I have a problem. It runs fine when I first start it and also if I pick home and then restart it; however, if I use the back arrow and then restart it it crashes on that time, but will work out the next time I start it. I think it has to do with some kind of memory build up, but I verified onDestroy is being called, I figured that deletes everything my program created, right?
I found the problem, I was loading a lot of bitmaps in Oncreate(), I did not realize that I had to release them under onDestroy(). I'm still a little surprized I have to do this as the API says they will be picked up by garbage collection when there is no longer a reference to them...like when my program is closed...

Categories

Resources