Example usage for android.util Log ERROR

List of usage examples for android.util Log ERROR

Introduction

In this page you can find the example usage for android.util Log ERROR.

Prototype

int ERROR

To view the source code for android.util Log ERROR.

Click Source Link

Document

Priority constant for the println method; use Log.e.

Usage

From source file:org.thoughtland.xlocation.Util.java

public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
        mLogDetermined = true;//from  ww  w .  j  a  va 2  s  . c o m
        try {
            mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false);
        } catch (Throwable ignored) {
            mLog = false;
        }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
        if (hook == null)
            Log.println(priority, "XLocation", msg);
        else
            Log.println(priority, String.format("XLocation/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (uid > 0 && priority == Log.ERROR)
        if (PrivacyService.isRegistered())
            PrivacyService.reportErrorInternal(msg);
        else
            try {
                IPrivacyService client = PrivacyService.getClient();
                if (client != null)
                    client.reportError(msg);
            } catch (RemoteException ignored) {
            }
}

From source file:com.google.android.gcm.demo.model.SenderCollection.java

private void loadSenders() {
    mSenders = new SimpleArrayMap<>();
    File file = new File(mContext.getFilesDir(), GCM_SENDERS_FILE);
    if (!file.exists() || file.length() == 0) {
        Sender entry = new Sender();
        entry.senderId = DEFAULT_SENDER_ID;
        entry.name = "Default";
        mSenders.put(DEFAULT_SENDER_ID, entry);
        saveSenders();//w  ww. j av a  2 s .com
        return;
    }
    int length = (int) file.length();
    byte[] bytes = new byte[length];
    FileInputStream in = null;
    // try-with-resources supported only starting with API 19 :-(
    try {
        in = new FileInputStream(file);
        int bytesRead = in.read(bytes);
        if (bytesRead == -1) {
            mLogger.log(Log.ERROR, "Failed to read senders file.");
        } else {
            JSONArray sendersJson = new JSONArray(new String(bytes));
            for (int i = 0; i < sendersJson.length(); i++) {
                Sender sender = Sender.fromJson(sendersJson.getJSONObject(i));
                mSenders.put(sender.senderId, sender);
            }
        }
    } catch (IOException e) {
        mLogger.log(Log.ERROR, "Failed to read senders file.", e);
    } catch (JSONException e) {
        mLogger.log(Log.ERROR, "Failed to deserialize senders.", e);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                // silently ignore
            }
        }
    }
}

From source file:biz.bokhorst.xprivacy.Util.java

public static void log(XHook hook, int priority, String msg) {
    // Check if logging enabled
    int uid = Process.myUid();
    if (!mLogDetermined && uid > 0) {
        mLogDetermined = true;//from   w  w  w  .  ja va 2 s  . c  o m
        try {
            mLog = PrivacyManager.getSettingBool(0, PrivacyManager.cSettingLog, false);
        } catch (Throwable ignored) {
            mLog = false;
        }
    }

    // Log if enabled
    if (priority != Log.DEBUG && (priority == Log.INFO ? mLog : true))
        if (hook == null)
            Log.println(priority, "XPrivacy", msg);
        else
            Log.println(priority, String.format("XPrivacy/%s", hook.getClass().getSimpleName()), msg);

    // Report to service
    if (uid > 0 && priority == Log.ERROR)
        if (PrivacyService.isRegistered())
            PrivacyService.reportErrorInternal(msg);
        else
            try {
                IPrivacyService client = PrivacyService.getClient();
                if (client != null)
                    client.reportError(msg);
            } catch (RemoteException ignored) {
            }
}

From source file:com.alyeska.shared.ane.iHAART.freInterface.MedicationAdministration.java

public MedicationAdministration(String administrationJSON) {
    try {//from  www  . j  a  va 2 s . c  o  m
        JSONObject administrationObject = new JSONObject(administrationJSON);
        _name = administrationObject.getString("name");
        _nameAbbrevAttr = administrationObject.getString("nameAbbrevAttr");
        _nameTypeAttr = administrationObject.getString("nameTypeAttr");
        _nameValueAttr = administrationObject.getString("nameValueAttr");
        _reportedBy = administrationObject.getString("reportedBy");
        _dateReported = Utilities.GetDateFromString(administrationObject.getString("dateReported"));
        _dateAdministered = Utilities.GetDateFromString(administrationObject.getString("_dateAdministered"));
        _amountAdministered_Value = administrationObject.getInt("_amountAdministered_Value");
        _amountAdministered_Unit = administrationObject.getString("_amountAdministered_Unit");
        _amountAdministered_UnitTypeAttr = administrationObject.getString("_amountAdministered_UnitTypeAttr");
        _amountAdministered_UnitValueAttr = administrationObject.getString("_amountAdministered_UnitValueAttr");
        _amountAdministered_UnitAbbrevAttr = administrationObject
                .getString("_amountAdministered_UnitAbbrevAttr");

    } catch (Exception e) {
        Utilities.LogItem(Log.ERROR, LOCAL_TAG, "administrationFromJSON failed with error: " + e.toString());
    }
}

From source file:com.android.utils.traversal.WorkingTree.java

public WorkingTree getNextSibling() {
    WorkingTree parent = getParent();/*from  w  w w  .  j a  va 2 s  .  c o  m*/
    if (parent == null) {
        return null;
    }

    int currentIndex = parent.mChildren.indexOf(this);
    if (currentIndex < 0) {
        LogUtils.log(Log.ERROR, "WorkingTree IllegalStateException: swap child not found");
        return null;
    }

    currentIndex++;

    if (currentIndex >= parent.mChildren.size()) {
        // it was last child
        return null;
    }

    return parent.mChildren.get(currentIndex);
}

From source file:com.googlecode.eyesfree.brailleback.FocusFinder.java

private static AccessibilityNodeInfoCompat findFirstFocusableDescendantInternal(
        AccessibilityNodeInfoCompat root, Context context, HashSet<AccessibilityNodeInfoCompat> seenNodes) {
    for (int i = 0, end = root.getChildCount(); i < end; ++i) {
        AccessibilityNodeInfoCompat child = root.getChild(i);
        if (child == null) {
            continue;
        }/*  w w w . j a va  2 s. c  om*/
        if (AccessibilityNodeInfoUtils.shouldFocusNode(context, child)) {
            return child;
        }
        if (!seenNodes.add(child)) {
            LogUtils.log(FocusFinder.class, Log.ERROR, "Cycle in node tree");
            child.recycle();
            return null;
        }
        AccessibilityNodeInfoCompat n = findFirstFocusableDescendantInternal(child, context, seenNodes);
        if (n != null) {
            return n;
        }
    }
    return null;
}

From source file:com.alyeska.shared.ane.iHAART.freInterface.Medication.java

public Medication(String medicationJSON) {
    try {/*from   w  ww.  j  a va  2s  .co  m*/
        JSONObject medObject = new JSONObject(medicationJSON);
        _name = medObject.getString("name");
        _nameAbbrevAttr = medObject.getString("nameAbbrevAttr");
        _nameTypeAttr = medObject.getString("nameTypeAttr");
        _nameValueAttr = medObject.getString("nameValueAttr");
        _scheduledBy = medObject.getString("scheduledBy");
        _recurrenceFrequency = medObject.getString("recurrenceFrequency");
        _recurrenceInterval = medObject.getInt("recurrenceInterval");
        _recurrenceCount = medObject.getInt("recurrenceCount");
        _doseValue = medObject.getInt("doseAmount");
        _doseUnitText = medObject.getString("doseUnit");
        _doseUnitTypeAttr = medObject.getString("doseUnitTypeAttr");
        _doseUnitValueAttr = medObject.getString("doseUnitValueAttr");
        _doseUnitAbbrevAttr = medObject.getString("doseUnitAbbrevAttr");
        _indication = medObject.getString("indication");
        _instructions = medObject.getString("instructions");
        _startTime = Utilities.GetDateFromString(medObject.getString("startTime"));
        _endTime = Utilities.GetDateFromString(medObject.getString("endTime"));
        _imgSource = medObject.getString("imgSource");
        _xmlString = medObject.getString("xmlString");

    } catch (Exception e) {
        Utilities.LogItem(Log.ERROR, LOCAL_TAG, "medicationFromJSON failed with error: " + e.toString());
    }
}

From source file:com.irccloud.android.RemoteInputService.java

@Override
protected void onHandleIntent(Intent intent) {
    boolean success = false;
    String sk = getSharedPreferences("prefs", 0).getString("session_key", "");
    if (intent != null && sk != null && sk.length() > 0) {
        final String action = intent.getAction();
        if (ACTION_REPLY.equals(action)) {
            Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
            if (remoteInput != null || intent.hasExtra("reply")) {
                Crashlytics.log(Log.INFO, "IRCCloud", "Got reply from RemoteInput");
                String reply = remoteInput != null ? remoteInput.getCharSequence("extra_reply").toString()
                        : intent.getStringExtra("reply");
                if (reply.length() > 0 && !reply.contains("\n/")
                        && (!reply.startsWith("/") || reply.toLowerCase().startsWith("/me ")
                                || reply.toLowerCase().startsWith("/slap "))) {
                    try {
                        JSONObject o = NetworkConnection.getInstance().say(intent.getIntExtra("cid", -1),
                                intent.getStringExtra("to"), reply, sk);
                        success = o.getBoolean("success");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }// w w w  .j a v a  2s. c  om
                }
                NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext())
                        .cancel(intent.getIntExtra("bid", 0));
                if (intent.hasExtra("eids")) {
                    int bid = intent.getIntExtra("bid", -1);
                    long[] eids = intent.getLongArrayExtra("eids");
                    for (int j = 0; j < eids.length; j++) {
                        if (eids[j] > 0) {
                            Notifications.getInstance().dismiss(bid, eids[j]);
                        }
                    }
                }
                if (!success)
                    Notifications.getInstance().alert(intent.getIntExtra("bid", -1), "Sending Failed",
                            reply.startsWith("/") ? "Please launch the IRCCloud app to send this command"
                                    : "Your message was not sent. Please try again shortly.");
            } else {
                Crashlytics.log(Log.ERROR, "IRCCloud", "RemoteInputService received no remoteinput");
            }
        }
    }
}

From source file:com.google.android.gcm.demo.model.TaskCollection.java

private void saveTasks() {
    File file = new File(mContext.getFilesDir(), GCM_TASKS_FILE);
    JSONArray jsonArray = new JSONArray();
    FileOutputStream out = null;//from   w ww  .java 2  s .  c o m
    try {
        for (int i = 0; i < mTasks.size(); i++) {
            TaskTracker task = mTasks.get(mTasks.keyAt(i));
            jsonArray.put(task.toJson());
        }
        out = new FileOutputStream(file);
        out.write(jsonArray.toString().getBytes());
    } catch (IOException e) {
        mLogger.log(Log.ERROR, "Failed to write tasks file.", e);
    } catch (JSONException e) {
        mLogger.log(Log.ERROR, "Failed to serialize tasks.", e);
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                // silently ignore
            }
        }
    }
}

From source file:com.android.utils.traversal.WorkingTree.java

public WorkingTree getPreviousSibling() {
    WorkingTree parent = getParent();/*w w  w .j a  v  a 2 s  . c o  m*/
    if (parent == null) {
        return null;
    }

    int currentIndex = parent.mChildren.indexOf(this);
    if (currentIndex < 0) {
        LogUtils.log(Log.ERROR, "WorkingTree IllegalStateException: swap child not found");
        return null;
    }

    currentIndex--;

    if (currentIndex < 0) {
        // it was first child
        return null;
    }

    return parent.mChildren.get(currentIndex);
}