M.ds M.ds - 1 year ago 77
Android Question

An Error With Using Log.i()

I'm trying to use a service in android studio(2.1.2) and I need to use Log.i() , but I have this error :The logging tag can be at most 23 characters. now I don't know how can I fix it !.

Here are my codes:

package com.example.n5110.intent;

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.n5110.intent";
public MyService() {

public int onStartCommand(Intent intent, int flags, int startId) {
Log.i(TAG,"onStartCommand called");

Runnable r = new Runnable() {
public void run() {
for(int i = 0; i<5; i++){
long futureTime = System.currentTimeMillis()+ 5000;
while (System.currentTimeMillis() < futureTime){
synchronized (this){
wait(futureTime - System.currentTimeMillis());
Log.i(TAG,"Service is busy");
}catch (Exception e){}
Thread buckysThread = new Thread(r);
return Service.START_STICKY;

public void onDestroy() {
Log.i(TAG,"onDestroy called");

public IBinder onBind(Intent intent) {
return null;

Does anyone have any idea??

Answer Source

Just make your tag shorter. Do you really need this tag in logs?

private static final String TAG ="MyService: ";

This should be enough

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download