Helo !
I am working right now with an application that uses BOOT_COMPLETED receiver.
So if I want to debug this application with some breakpoints in its class, I have to reboot my phone and connect to it in the proper time, but I am always too late.
Have you got any better solutions how to debug my application exact when it starts its lifetime with device reboot case ?
Thanks !
You can wait for a debugger - Debug.waitForDebugger()
Close your emulator and Run the application directly in Debug and select the option to launch the emulator that you want to run it on.
It's an strange thing, but, what if you put a 20 sec pause or loop before your first break point?
In this case logging is better solution than debuggung. I was able to see logs arising from BOOT_COMPLETE processing even in IDEA logcat window. (I also do not value step by step debugging very much, and prefer TDD approach anyway)
Related
I hired a developer to build an app for me, I noticed this issue and he said he doesn't think (or know how) it could be fixed. The issue is that every time my app is launched and you're logged in, this notification appears and stays there even if you close the app, you cannot swipe to remove it, you can either remove the app or kill it, or reboot the phone. Any idea how to fix it, he's using "Pusher"
Here's the example after launching the app
You have to manage your service so that it can be started and stooped as per your usage.
Please post the code or connect with me # napsterkr#gmail.com for further help.
I have an app that also has a NotificationListenerService. When I add breakpoints in that NotificationListenerService, it appears that the breakpoints halt the execution, but the debugger does not recognize it.
The debugger does not seem to see that the execution has paused, and does not activate the continue button nor does it show anything in the service as far as variables. Once this happens the first time, it appears that the service is stopped permanently.
A reboot seems to get things going again sometimes but only if you run the app in normal mode (not debugger mode) before you shut the device off. I tried reattaching the debugger as well, and that does not seem to work. Strangely, I did get it working once or twice. Not sure how.
Does anyone know how to attach the debugger correctly so you can debug the NotificationListenerService?
I found this potentially related question:
NotificationListenerService stopping and can't be restarted without a reboot
Why is this NotificationListenerService not working
, but neither have good answers and neither discuss using the debugger.
The NotificationListenerService runs on your main application thread. So to debug first set the debug points and then from Android studio toolbar select "Attach debugger to Android process".
Select your application main process. Now you will be able to debug your service. Hope it helps!
Cheers
My App sends out GPS data with a timer. Sometimes I block the screen.
Now with some phones and only sometimes I have the problem that the OS somehow blocks the data packages and only releases them later, when the screen is unlocked. The messages still are getting sent from the app but only stopped in android.
Anybody have a Idea why that happens and how I can stop it?
Is it possible that those devices are going to sleep (or sending the radio to sleep)? Have you tried setting a wakelock to prevent this? https://developer.android.com/reference/android/os/PowerManager.WakeLock.html
I suspect your application goes to sleep, or your wifi. There are applications specifically designed to keep your wifi alive, so i suspect it does sleep. Were i to create the wifi, i would definitely make it sleep when there wasnt anything to say.
To test download one of the apps. That and write to a log file when your application is going to sleep.
Sorry i couldnt give a specific answer. Id have posted this as a comment, but im too new to be able to do that.
I am testing the onsave/onrestore mthods of my android application.
To do this I phone my device and see that it kills the process and then I hang up. :)
I see that it restarts the application.
Question is: how do I cause it to restart in debug mode so I can step through the restore process?
Is there a way to tell it to automatically attach to the debugger when starting up?
Use android.os.Debug.waitForDebugger();
Basically, start via debugging. Exit out of your app. Set some break points. Enter back into your app (make sure that this line is hit, so put it in your onCreate or somewhere else) and it will re-attach to the running debugger.
I don't think there is a way to ensure the app restarts in debug mode. But if you are debugging your own app and don't mind adding debug code for testing you might want to add a Thread.sleep(5000) or something like this at an appropriate place in your startup methods. This should give you enough time to reconnect the debugger via the DDMS. Remove when you are done, of course ;)
There is a configuration option in Android settings > developer options > debugging > select app to be debugged. What it does is calling the eclipse debugger every time certain application is opened, if it's connected to the adb and the app's project is open.
Programmatically: Use waitForDebugger(). Documentation here.
Note that the method returns as soon as the debugger attaches, so it's best practice to place a breakpoint right after that call. Additionally, you can test the debugger attachment status using isDebuggerConnected().
In Eclipse: Open the DDMS perspective of eclipse, select the freshly-restarted app on your device, and then select the debug option. This will attach the debugger to the restarted instance.
On the Device: There is a configuration option under some* handsets that allows you to select an app to be debugged when USB debugging is configured. It's under the Developer Options in your device settings. This will attach the debugger automatically.
*For example, my Galaxy S4 has it, my HTC Rezound does not. I believe it might be a Jelly Bean specific option.
I am quite new to Android and have a debugging issue. I know what an ANR is for, and do not see them when I run my app normally. However, when I try to debug my BoradcastReceiver, I am too slow and get the ANR message.
Is there a way to switch off ANR during debug sessions? I could use log statement to see what's happening, but this is annoying....
edit: actually, I don't want to supress the ANRs in the LogCat, I want to tell android not to throw ANRs during debugging. I mean to allow Broadcast receivers to take longer than 5 seconds to run. But I guess it will not be possible and instead I should delegate to a service, which is allowed to run longer, which I also can debug easier.
Thanks in advance!
greets
Go to Settings -> Developer options and check Show all ANRs.
This will show an App Not Responding dialog for apps running in the background. You can click the Wait button in the dialog to prevent the system from killing your process. Note that the dialog is opened automatically for apps running in the foreground. For background apps, you have to enable this option.
No. This message is handled through the Android OS, not your application, and there is no way to hide it on the Emulator. If you don't want to see it and your BroadcastReceiver receives the call correctly, just doesn't run successful code, you can use a try-catch block, and instead of your application crashing, the catch will be handled, wherein you can make a Toast message or whatever you wish.
You may find this resource useful for your problem. Key points:
Use -w to make process wait until debugger is attached. This one actually helps to stop on breakpoints on onCreate()'s. Debug flag is cleared after you attach debugger. Next time app starts in a regular way.
Use --persistent to wait for debugger every time process starts.
Use adb shell am clear-debug-app your.app.package to undo --persistent