List of usage examples for android.util Log WARN
int WARN
To view the source code for android.util Log WARN.
Click Source Link
From source file:Main.java
/** * Logs provided logText in provided tag at given logLevel (like, android.util.Log.DEBUG) * @param logLevel int VERBOSE, DEBUG, INFO, WARN, ERROR * @param tag String/*from www. j ava 2s.c o m*/ * @param logText String */ public static void log(int logLevel, String tag, String logText) { switch (logLevel) { case Log.VERBOSE: Log.v(tag, logText); break; case Log.DEBUG: Log.d(tag, logText); break; case Log.INFO: Log.i(tag, logText); break; case Log.WARN: Log.w(tag, logText); break; case Log.ERROR: Log.e(tag, logText); break; } }
From source file:de.escoand.readdaily.ReminderHandler.java
public static void startReminder(final Context context, final int hour, final int minute) { Intent intent = new Intent(context, ReminderHandler.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Activity.ALARM_SERVICE); GregorianCalendar cal = new GregorianCalendar(); // get next reminder cal.set(Calendar.HOUR_OF_DAY, hour); cal.set(Calendar.MINUTE, minute); cal.set(Calendar.SECOND, 0);/*from w ww. j a va2s .c o m*/ cal.set(Calendar.MILLISECOND, 0); if (cal.before(Calendar.getInstance())) cal.add(Calendar.DATE, 1); am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 24 * 60 * 60 * 1000, pendingIntent); LogHandler.log(Log.WARN, "activated " + hour + ":" + minute); }
From source file:Main.java
public static void w(String tag, String msg) { print(Log.WARN, tag, msg); }
From source file:de.escoand.readdaily.ReminderHandler.java
public static void endReminder(final Context context) { Intent intent = new Intent(context, ReminderHandler.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Activity.ALARM_SERVICE); am.cancel(pendingIntent);//from w w w . java2s .c o m LogHandler.log(Log.WARN, "deactivated"); }
From source file:de.escoand.readdaily.PushMessageService.java
@Override public void onMessageReceived(final RemoteMessage remoteMessage) { RemoteMessage.Notification notification = remoteMessage.getNotification(); String title = getString(R.string.app_title); String message = ""; Intent intent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); LogHandler.log(Log.WARN, "received message"); // get title//from w w w . jav a 2 s .c om if (notification != null && notification.getTitle() != null && !notification.getTitle().isEmpty()) title = notification.getTitle(); // get message if (notification != null && notification.getBody() != null && !notification.getBody().isEmpty()) message = notification.getBody(); else if (remoteMessage.getData().containsKey("message")) message = remoteMessage.getData().get("message"); // build notification NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.icon_notification) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setContentTitle(title).setContentText(message).setAutoCancel(true) .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setContentIntent(pendingIntent); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)) .notify((int) remoteMessage.getSentTime(), builder.build()); }
From source file:de.escoand.readdaily.DownloadHandler.java
public static long startDownload(@NonNull final Context context, @NonNull final String signature, @NonNull final String responseData, @NonNull final String title, @Nullable final String mimeType) { final DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); String name;//from w ww . j av a2 s . c o m try { name = new JSONObject(responseData).getString("productId"); } catch (JSONException e) { LogHandler.log(e); return -1; } LogHandler.log(Log.WARN, "load " + name); long id = manager .enqueue(new DownloadManager.Request(Uri.parse(context.getString(R.string.product_data_url))) .addRequestHeader("App-Signature", signature) .addRequestHeader("App-ResponseData", responseData).setTitle(title) .setDescription(context.getString(R.string.app_title))); Database.getInstance(context).addDownload(name, id, mimeType); return id; }
From source file:com.example.android.common.logger.LogView.java
/** * Formats the log data and prints it out to the LogView. * @param priority Log level of the data being logged. Verbose, Error, etc. * @param tag Tag for for the log data. Can be used to organize log statements. * @param msg The actual message to be logged. The actual message to be logged. * @param tr If an exception was thrown, this can be sent along for the logging facilities * to extract and print useful information. *//*from www . j ava 2 s .c om*/ @Override public void println(int priority, String tag, String msg, Throwable tr) { String priorityStr = null; // For the purposes of this View, we want to print the priority as readable text. switch (priority) { case android.util.Log.VERBOSE: priorityStr = "VERBOSE"; break; case android.util.Log.DEBUG: priorityStr = "DEBUG"; break; case android.util.Log.INFO: priorityStr = "INFO"; break; case android.util.Log.WARN: priorityStr = "WARN"; break; case android.util.Log.ERROR: priorityStr = "ERROR"; break; case android.util.Log.ASSERT: priorityStr = "ASSERT"; break; default: break; } // Handily, the Log class has a facility for converting a stack trace into a usable string. String exceptionStr = null; if (tr != null) { exceptionStr = android.util.Log.getStackTraceString(tr); } // Take the priority, tag, message, and exception, and concatenate as necessary // into one usable line of text. final StringBuilder outputBuilder = new StringBuilder(); String delimiter = "\t"; appendIfNotNull(outputBuilder, priorityStr, delimiter); appendIfNotNull(outputBuilder, tag, delimiter); appendIfNotNull(outputBuilder, msg, delimiter); appendIfNotNull(outputBuilder, exceptionStr, delimiter); // In case this was originally called from an AsyncTask or some other off-UI thread, // make sure the update occurs within the UI thread. ((Activity) getContext()).runOnUiThread((new Thread(new Runnable() { @Override public void run() { // Display the text we just generated within the LogView. appendToLog(outputBuilder.toString()); } }))); if (mNext != null) { mNext.println(priority, tag, msg, tr); } }
From source file:com.ameron32.apps.tapnotes._unused.original.LoginFragmentBase.java
protected void debugLog(String text) { if (Parse.getLogLevel() <= Parse.LOG_LEVEL_DEBUG && Log.isLoggable(getLogTag(), Log.WARN)) { Log.w(getLogTag(), text);//from w w w. ja v a 2 s .c o m } }
From source file:com.android.utils.traversal.NodeCachedBoundsCalculator.java
private Rect getBoundsInternal(AccessibilityNodeInfoCompat node) { if (node == null) { return EMPTY_RECT; }//from ww w .ja va 2 s .c o m if (mCalculatingNodes.contains(node)) { LogUtils.log(Log.WARN, "node tree loop detected while calculating node bounds"); return EMPTY_RECT; } Rect bounds = mBoundsMap.get(node); if (bounds == null) { mCalculatingNodes.add(node); bounds = fetchBound(node); mBoundsMap.put(node, bounds); mCalculatingNodes.remove(node); } return bounds; }
From source file:org.thoughtland.xlocation.UpdateService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { // Check if work if (intent == null) { stopSelf();/*from w ww. j av a2 s. com*/ return 0; } // Flush if (cFlush.equals(intent.getAction())) { try { PrivacyService.getClient().flush(); } catch (Throwable ex) { Util.bug(null, ex); } stopSelf(); return 0; } // Update if (cUpdate.equals(intent.getAction())) { if (Util.hasProLicense(this) != null) { int userId = Util.getUserId(Process.myUid()); boolean updates = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingUpdates, false); if (updates) new ActivityShare.UpdateTask(this).execute(); } stopSelf(); return 0; } // Check action Bundle extras = intent.getExtras(); if (extras.containsKey(cAction)) { final int action = extras.getInt(cAction); Util.log(null, Log.WARN, "Service received action=" + action + " flags=" + flags); // Check service if (PrivacyService.getClient() == null) { Util.log(null, Log.ERROR, "Service not available"); stopSelf(); return 0; } // Start foreground service NotificationCompat.Builder builder = new NotificationCompat.Builder(UpdateService.this); builder.setSmallIcon(R.drawable.ic_launcher); builder.setContentTitle(getString(R.string.app_name)); builder.setContentText(getString(R.string.msg_service)); builder.setWhen(System.currentTimeMillis()); builder.setAutoCancel(false); builder.setOngoing(true); Notification notification = builder.build(); startForeground(Util.NOTIFY_SERVICE, notification); // Start worker mWorkerThread = new Thread(new Runnable() { @Override public void run() { try { // Check action if (action == cActionBoot) { // Boot received migrate(UpdateService.this); upgrade(UpdateService.this); randomize(UpdateService.this); } else if (action == cActionUpdated) { // Self updated upgrade(UpdateService.this); } else Util.log(null, Log.ERROR, "Unknown action=" + action); // Done stopForeground(true); stopSelf(); } catch (Throwable ex) { Util.bug(null, ex); // Leave service running } } }); mWorkerThread.start(); } else Util.log(null, Log.ERROR, "Action missing"); return START_STICKY; }