Android服务没有显示日志?

时间:2015-09-15 03:07:05

标签: android

我有点困惑,

似乎我的服务不打印日志,

服务定期启动(我可以调试它),我看到所有其他日志,

但是从服务中没有日志。

请问我在这里缺少什么?

@Override
protected void onHandleIntent(Intent intent) {
    Log.e("TAG","Downlaoding devices list");//This should log something!

4 个答案:

答案 0 :(得分:2)

有可能你的IntentService没有被调用。尝试使用IntentService的整个包名。我已经看到了这个地方,如果我发现它,我会发布一个链接。 像这样......

Intent intent = new Intent(this/*Context*/,com.myapp.MyIntentService.class); //as opposed to // new Intent(this, MyIntentService.class); startService(intent);

编辑:我找到了链接。 intentService : why my onHandleIntent is never called?

答案 1 :(得分:1)

我的解决方案是在logcat微调器中选择“No filters”而不是“Show only selected application”。然后你可以搜索TAG或你知道应该显示的任何内容。

答案 2 :(得分:1)

在Android Studio Logcat中。 在运行代码之前 1)选择No Filters而不是Show selected applications 2)在搜索框中,键入您的标签。 3)现在运行您的代码,将显示所有日志。

注意:如果您在运行代码后输入代码,则无效。

答案 3 :(得分:0)

在我的Himax M2 Y12手机的情况下,我的TAG SensorService因未知原因被阻止,因此具有特殊性。

我将TAG更改为GeoSensorService,现在显示了logcat。

我的猜测是他们保留TAG用于内部目的,但我认为他们不应该使用这样一个无辜的命名(他们可以用__或其他东西预先标记保留的TAG )。

相关问题