Logcat不显示调试标记

时间:2013-11-10 07:32:06

标签: android android-logcat

我正在开发一款应用。其中我在活动中使用工作线程。我的应用程序有一些问题,并试图找出使用调试标签的问题。但是logcat不显示线程内的标记。我是新手,所以对此不太了解..

这是代码..

package com.example.forgetmenot;

import java.util.ArrayList;
import java.util.Calendar;

import android.app.Service;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;

public class BirthdayService extends Service{

    SQLiteDatabase db;
    BirthdayDatabase myDatabase = new BirthdayDatabase(this, null, null, 0);
    private ArrayList<String> data = new ArrayList<String>();
    Handler handler = new Handler();
    String form[] ={"_id","name","contact","day","month","year"};
    String TAG = "Debug";
    @Override
    public IBinder onBind(Intent arg0) {

        return null;
    }

    @Override
    public void onCreate() {
//      Toast.makeText(this,"birthday Service started", Toast.LENGTH_SHORT).show();
        super.onCreate();
    }

    @Override
    public void onDestroy() {

        super.onDestroy();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Calendar cal = Calendar.getInstance();

        new Thread(new Runnable() {

            @Override
            public void run() {
                Calendar cal = Calendar.getInstance();
                int mDay = cal.get(Calendar.DAY_OF_MONTH);
                int mMonth = cal.get(Calendar.MONTH);
                Log.d(TAG, "Current day: "+mDay);
                Log.d(TAG,"Current month: "+mMonth);
                int birthDay = 0;
                int birthMonth = 0;
                final Cursor mycursor = db.query("birthdays", form, null, null, null, null, null, null);
                while(mycursor.moveToNext()){
                    birthDay = mycursor.getInt(3);
                    birthMonth = mycursor.getInt(4);
                    Log.d(TAG, "birhDay:"+birthDay);
                    Log.d(TAG, "birthMonth:"+birthMonth);
                    if(mDay == birthDay && mMonth == birthMonth)
                    {
                        handler.post(new Runnable() {

                            @Override
                            public void run() {

                                Toast.makeText(getBaseContext(), "Happy Birthday "+mycursor.getString(1), Toast.LENGTH_SHORT).show();
                            }

                        });

                        db.close();
                        break;
                    }
                }
                db.close();

            }

        });

        Toast.makeText(this, "BirthdayService", Toast.LENGTH_SHORT).show();
        return 0;
    }

}

2 个答案:

答案 0 :(得分:0)

您必须确保在设备信息标签中选择了哪个模拟器或设备, 如果你还没找到它,那么请重置adb,然后请选择你的模拟器,然后再试一次,

仍然会遇到同样的问题,然后重新启动你的eclipse或adb。

答案 1 :(得分:0)

启动您在onStartCommand

中创建的主题