LoginSignup
1
0

More than 5 years have passed since last update.

intentの中身をvar_dumpしたい

Posted at

やりたいこと

他所のアプリとかから結果を受け取ったりすることがある。QRやNFCを読んだ結果とか。

そういう場合、多くはonNewIntent(Intent intent)に処理を書く。

ところで、このIntentの中身を確認したい、という状況が起きた。

PHPならvar_dumpで出せるのに、と思いつつ頑張ることになった。

解答

public var_dump(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null && !extras.isEmpty()) {
        System.out.println("+ Bundle.toString: " + extras.toString() + "");

        for (final String key : extras.keySet()) {
            System.out.println("+ Key Name: " + key + "");
            System.out.println("+ toString: " + extras.get(key).toString() + "");
        }
    }
}
1
0
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
1
0