0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AndroidStudio: ログメッセージの出し方

Posted at

次のページを参考にしました。
logcat を使用してログを書き込み、表示する

次のログメソッドがあります。

エラー: Log.e(String, String)
警告: Log.w(String, String)
情報: Log.i(String, String)
デバッグ: Log.d(String, String)
詳細: Log.v(String, String)

プログラム

MainActivity.kt
package com.example.log01

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log

private const val TAG = "MyActivity"
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val aa = 123
        val bb = 345
        val cc = aa + bb

        Log.i(TAG, "*** onCreate *** aa = $aa")
        Log.i(TAG, "*** onCreate *** bb = $bb")
        Log.i(TAG, "*** onCreate *** cc = $cc")

    }
}

実行結果

image.png

image.png

0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?