HOW WOULD YOU PRINT A MESSAGE IN THE LOGCAT AND PREVENT THE APPLICATION TO GET STARTED?

0 votes
179 views
Shlok Srivastava asked 23-Jan-2018 in Technology by Shlok Srivastava

HOW WOULD YOU PRINT A MESSAGE IN THE LOGCAT AND PREVENT THE APPLICATION TO GET STARTED?

1 Answer

0 votes
Arti Mishra answered 16-May-2018 by Arti Mishra
Logcat window in Android:
Generally, Lolcat window is used for displaying some message in android studio, such as displaying system messages, any types of error or exception, and add some messages in your android app with the Log class.
The Log class allows you to create log messages that appear in logcat window. And you should also use the following log methods to print message in logcat.

Printing  Message in Logcat window :
  • Log.e(Tag, Message) ---- display error message.
  • Log.w(Tag, Message) ---- display warning message.
  • Log.i(Tag, Message) ---- display information message.
  • Log.d(Tag, Message) ---- display debug message.
  • Log.v(Tag, Message) ---- display verbose message.

For restarting your app use following code in your android application.
Intent i = getBaseContext().getPackageManager(). getLaunchIntentForPackage(getBaseContext().getPackageName()); 
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);