Auto-generate Android Log TAG in Android Studio/Intellij idea

Solution 1:

I find a solution

1) Create a new live template in plain group
2) In template text :

private static final String TAG = $CLASS_NAME$.class.getSimpleName();

3) Define a usage scope :

enter image description here

4) Choose a shortcut :

enter image description here

finally click on Edit variables and change expression value to className()

enter image description here

Click Ok , Apply, Ok and use.

Solution 2:

There already exists such shortcut in Android Studio - write logt and enter while cursor is at the class scope.

more here :

for more see here

Solution 3:

It's super simple in Android studio, just type logt and press Tab.

It generates: private static final String TAG = "xyzActivity";