在 Android Studio 中调试服务的正确方法? [英] A proper way to Debug a Service in Android Studio?
问题描述
是否有正确的方法在 Android Studio 中调试服务?或者 Android Studio 无法做到这一点?当我尝试调试时,它只会断开套接字的连接.("与目标虚拟机断开连接,地址:'localhost:8600',传输'socket')
Is there a proper way to debug a service in Android Studio? Or Android Studio could not do this? When I try to debug, it will just disconnects the sockets. ("Disconnected from the Target VM, address:'localhost:8600',transport 'socket')
希望你能在这里帮助我..
Hopefully you can assist me here..
我通过这里的一些链接作为建议所做的,我已经放置了 .waitForDebugger 但没有任何反应.请帮助我..非常感谢.
What I have done as advice by some links here, I had place the .waitForDebugger but nothing happens. Please help me.. Thank you very much.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent mainService = new Intent(this,MainPowerAndVolumeService.class);
startService(mainService);
android.os.Debug.waitForDebugger();
finish();
}
推荐答案
run in debug"旁边有一个按钮(在 1.1.0 版本中看起来像这样:) 将调试器附加到正在运行的 android 进程.这是官方信息(对于 IntelliJ,但在 Android Studio 中是相同的):http://blog.jetbrains.com/idea/2011/05/new-in-105-attach-debugger-to-a-running-android-process/
There is a button next to "run in debug" (In version 1.1.0 looks like this: ) to attach the debugger to a running android process. Here is the official info (for IntelliJ, but it's the same in Android Studio): http://blog.jetbrains.com/idea/2011/05/new-in-105-attach-debugger-to-a-running-android-process/
这篇关于在 Android Studio 中调试服务的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!