I am a newbie of Android Studio. I have a problem with display the logs in my app. For example:
String timeStamp = new
SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cycle);
TextView textView = (TextView) findViewById(R.id.cykleoncreate);
Log.d("[ " timeStamp "]", "[onCreate]");
I only want to display this log in my app. How can I do it?
CodePudding user response:
you can display the logs by Toast or set in textView
Toast.makeText(getApplicationContext(),timeStamp,Toast.LENGTH_SHORT).show();
or
textView.setText(timeStamp);
CodePudding user response:
What you have done is write but you can get confused as in where's the log, Log has tag
and message
, Tags are usually Activity or fragment name so that its easier for one to locate from where did a particular error
or message
came from, and you can include anything in the message part of it.
we have different types of logs
this can be We can display like this Log.d("onCreate", timeStamp);
and search using TAG as onCreate.