2017-05-09 6 views
0

TAGの値は、以下に示すようにアンドロイドスタジオのパッケージの名前にするのがいいですか?ロギングタグは最大23文字になりますか?TAGの価値はいくらですか?

package com.example.swangmo.intentexample; 

import android.app.Service; 
import android.content.Intent; 
import android.os.IBinder; 
import android.util.Log; 

public class MyService extends Service { 
    private static final String TAG="com.example.swangmo.intentexample"; 
    public MyService() { 
    } 

    @Override 
    public IBinder onBind(Intent intent) { 
     // TODO: Return the communication channel to the service. 
     throw new UnsupportedOperationException("Not yet implemented"); 
    } 

    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) { 
     return super.onStartCommand(intent, flags, startId); 
    } 

    @Override 
    public void onDestroy() { 
     Log.i(TAG,"onDestroy method called"); 
    } 
} 
+0

任意のタグを設定できます。これはロギング用です。そこにパッケージを置くことは必要ではありません。私は個人的に決してしません。 AndroidはTAGを23文字に調整します。あなたがコンソールに欲しかったように正確に見たい場合は、それをatmost 23文字にしておいてください。 – mhenryk

+0

あなたの答えをお返事ありがとうございます – sangay

答えて

0

TAG内の任意の文字列は、パッケージ名でなくてもかまいません。しかし条件は24文字以下、つまり最大23文字で、それ以上ではないという条件です。

+0

あなたのお返事ありがとうございます – sangay

+0

ようこそ..... :) –

0

TAGは(静的最終的な)文字列です。ランタイムログを解析しやすくするために、任意の値に設定します。

関連する問題