在Android Studio中调试服务的正确方法?

The*_*One 12 service android android-studio

有没有正确的方法在Android Studio中调试服务?或Android Studio无法做到这一点?当我尝试调试时,它只会断开套接字.("与目标VM断开连接,地址:'localhost:8600',传输'套接字')

希望你能在这里帮助我..

我在这里通过一些链接做了什么建议,我放了.waitForDebugger但没有任何反应.请帮帮我..非常感谢你.

   @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent mainService = new Intent(this,MainPowerAndVolumeService.class);

    startService(mainService);
    android.os.Debug.waitForDebugger();

    finish();

}
Run Code Online (Sandbox Code Playgroud)

Ori*_*olJ 13

"在调试中运行"旁边有一个按钮(在版本1.1.0中看起来像这样: 覆盖着小虫子的电话图标)将调试器附加到正在运行的android进程.以下是官方信息(对于IntelliJ,但在Android Studio中也是如此):http: //blog.jetbrains.com/idea/2011/05/new-in-105-attach-debugger-to-a-running- Android的进程/