I'm trying to use the format() to print a string, but it's failing. The error is:
java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.Console java.io.Console.format(java.lang.String, java.lang.Object[])' on a null object reference
Here's the code snippet. Would appreciate any tips
public class BootNotifier extends BroadcastReceiver
{
public String TAG = "BootNotifier";
Console console = System.console();
String fmt = "%s";
String msg = "Android boot completed successfully";
@Override
public void onReceive(Context context, Intent intent)
{
Log.e(TAG, "onReceive");
if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction()))
{
Log.e(TAG, "onReceive: BOOT_COMPLETED");
console.format(fmt, msg);
}
}
}