在Android Studio中调试服务的正确方法? [英] A proper way to Debug a Service in Android Studio?

查看:102
本文介绍了在Android Studio中调试服务的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有在Android Studio中调试服务的正确方法?还是Android Studio无法做到这一点?当我尝试调试时,它只会断开套接字. (与目标VM断开连接,地址:'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();

}

推荐答案

在调试中运行"旁边有一个按钮(在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆