I am beginner in learning android java. I learning the java android tutorial from Youtube and I follow exactly the coding from the video, but my coding showing "cannot resolve symbol 'tag' " on the android studio. May I know what is the problem? and hope to get explanation from all the master here.
package com.NewApplicationLifeCycle;
import ...
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.i( tag: "State", msg: "onCreate" );
}
@Override
protected void onStart() {
super.onStart();
Log.i( tag: "State", msg: "onStart" );
}
@Override
protected void onResume() {
super.onResume();
Log.i( tag: "State", msg: "onResume" );
}
@Override
protected void onPause() {
super.onPause();
Log.i( tag: "State", msg: "onPause" );
}
@Override
protected void onStop() {
super.onStop();
Log.i( tag: "State", msg: "onStop" );
}
@Override
protected void onRestart() {
super.onRestart();
Log.i( tag: "State", msg: "onRestart" );
}
@Override
protected void onDestroy() {
super.onDestroy();
Log.i( tag: "State", msg: "onDestroy" );
}
}
IDEs give you more context about the parameters of the function you're calling by highlighting the parameter names. Like in this case Log.i(tag: String, msg: String)
accepts two parameters tag
and msg
but you don't have to write them yourself when calling the function.
Remove tag:
and msg:
from Log.i(...)
calls and call it like this:
Log.i( "State", "onRestart" );
and so on for others as well.
use like this
var tag = "your tag name"
var msg = "you message"
Log.i( tag +"State", msg+ "onCreate" );
otherwise :-
Log.d(tag, message)
Log.i( "your tag name","your message" );
and check this official link
how can i Write and View Logs with Logcat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With