LoginSignup
2
1

More than 5 years have passed since last update.

Androidで表示しているActivity名を取得する

Posted at

下記のようにActivityのgetComponentName()から、フルパッケージを含むクラス名を取得できます。

package jp.hitting;

class HogeClass extends Activity {

    void hoge() {
        getComponentName().getClassName(); // jp.hitting.HogeClass
    }

}

getComponentName()で取得できるComponentNameからは、フルパッケージを含むクラス名の他に、パッケージを短縮したクラス名や、パッケージ名のみを取得することができます。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1