Example usage for android.util Log DEBUG

List of usage examples for android.util Log DEBUG

Introduction

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

Prototype

int DEBUG

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

Click Source Link

Document

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

Usage

From source file:com.variable.demo.api.fragment.MotionFragment.java

@Override
public void onMagnetometerUpdate(MotionSensor sensor, MotionReading reading) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_MAGNETOMETER_READING);
    Bundle b = m.getData();/*  ww w.j  a  v a 2s .  c o m*/
    b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 6) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 6) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 6) * DECIMAL_PRECISION);

    //For this demo we are streaming all time stamp from the node device.
    b.putLong(MessageConstants.TIME_STAMP, reading.getTimeStamp().getTime());
    b.putInt(MessageConstants.TIME_SOURCE, reading.getTimeStampSource());

    final Context thiscontext = this.getActivity();
    final String serialnumOne = sensor.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scanX = Float.toString((reading.getX() + 16) * DECIMAL_PRECISION);
    final String scanY = Float.toString((reading.getY() + 16) * DECIMAL_PRECISION);
    final String scanZ = Float.toString((reading.getZ() + 16) * DECIMAL_PRECISION);
    String json = "magnetometer;" + serialnum + ";" + scanX + "," + scanY + "," + scanZ;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });

    m.sendToTarget();
}

From source file:com.variable.demo.api.fragment.ClimaFragment.java

@Override
public void onClimaTemperatureUpdate(ClimaSensor clima, SensorReading<Float> temperature) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_CLIMA_TEMPERATURE);
    m.getData().putFloat(MessageConstants.FLOAT_VALUE_KEY, temperature.getValue());
    // convert the UTF
    final Context thiscontext = this.getActivity();
    final DecimalFormat formatter = new DecimalFormat("0.00");
    final String serialnumOne = clima.getSerialNumber();
    final String serialnum = serialnumOne.replaceAll("[^\\u0000-\\uFFFF]", "");
    final String scann = formatter.format(temperature.getValue());
    String json = "temperature;" + serialnum + ";" + scann;

    // POST to variable dashboard
    Ion.getDefault(thiscontext).getConscryptMiddleware().enable(false);
    Ion.with(thiscontext).load(/*from   www.  j av  a  2 s.  c  o  m*/
            "https://datadipity.com/clickslide/fleetplusdata.json?PHPSESSID=gae519f8k5humje0jqb195nob6&update&postparam[payload]="
                    + json)
            .setLogging("MyLogs", Log.DEBUG).asString().withResponse()
            .setCallback(new FutureCallback<Response<String>>() {
                @Override
                public void onCompleted(Exception e, Response<String> result) {
                    if (e == null) {
                        Log.i(TAG, "ION SENT MESSAGE WITH RESULT CODE: " + result.toString());
                    } else {
                        Log.i(TAG, "ION SENT MESSAGE WITH EXCEPTION");
                        e.printStackTrace();
                    }
                }
            });
    m.sendToTarget();
}

From source file:com.yzx.frames.tool.view_self.percent.PercentLayoutHelper.java

/**
 * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from
 * {@code LayoutParams(Context c, AttributeSet attrs)} constructor.
 *//* w  w w. j  a  v a  2  s. c  o  m*/
public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) {
    PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout);
    float value = array.getFraction(R.styleable.PercentLayout_Layout_layout_widthPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent width: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.widthPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_heightPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent height: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.heightPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.leftMarginPercent = value;
        info.topMarginPercent = value;
        info.rightMarginPercent = value;
        info.bottomMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent left margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.leftMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent top margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.topMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent right margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.rightMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent bottom margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.bottomMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent start margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.startMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent end margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.endMarginPercent = value;
    }

    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_aspectRatio, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "aspect ratio: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.aspectRatio = value;
    }

    array.recycle();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "constructed: " + info);
    }
    return info;
}

From source file:com.android.calendar.alerts.AlarmScheduler.java

/**
 * Queries for all the reminders of the events in the instancesCursor, and schedules
 * the alarm for the next upcoming reminder.
 *///from  w  w  w . j  a va2 s .  c  om
private static void queryNextReminderAndSchedule(Cursor instancesCursor, Context context,
        ContentResolver contentResolver, AlarmManagerInterface alarmManager, int batchSize,
        long currentMillis) {
    if (AlertService.DEBUG) {
        int eventCount = instancesCursor.getCount();
        if (eventCount == 0) {
            Log.d(TAG, "No events found starting within 1 week.");
        } else {
            Log.d(TAG, "Query result count for events starting within 1 week: " + eventCount);
        }
    }

    // Put query results of all events starting within some interval into map of event ID to
    // local start time.
    Map<Integer, List<Long>> eventMap = new HashMap<Integer, List<Long>>();
    Time timeObj = new Time();
    long nextAlarmTime = Long.MAX_VALUE;
    int nextAlarmEventId = 0;
    instancesCursor.moveToPosition(-1);
    while (!instancesCursor.isAfterLast()) {
        int index = 0;
        eventMap.clear();
        StringBuilder eventIdsForQuery = new StringBuilder();
        eventIdsForQuery.append('(');
        while (index++ < batchSize && instancesCursor.moveToNext()) {
            int eventId = instancesCursor.getInt(INSTANCES_INDEX_EVENTID);
            long begin = instancesCursor.getLong(INSTANCES_INDEX_BEGIN);
            boolean allday = instancesCursor.getInt(INSTANCES_INDEX_ALL_DAY) != 0;
            long localStartTime;
            if (allday) {
                // Adjust allday to local time.
                localStartTime = Utils.convertAlldayUtcToLocal(timeObj, begin, Time.getCurrentTimezone());
            } else {
                localStartTime = begin;
            }
            List<Long> startTimes = eventMap.get(eventId);
            if (startTimes == null) {
                startTimes = new ArrayList<Long>();
                eventMap.put(eventId, startTimes);
                eventIdsForQuery.append(eventId);
                eventIdsForQuery.append(",");
            }
            startTimes.add(localStartTime);

            // Log for debugging.
            if (Log.isLoggable(TAG, Log.DEBUG)) {
                timeObj.set(localStartTime);
                StringBuilder msg = new StringBuilder();
                msg.append("Events cursor result -- eventId:").append(eventId);
                msg.append(", allDay:").append(allday);
                msg.append(", start:").append(localStartTime);
                msg.append(" (").append(timeObj.format("%a, %b %d, %Y %I:%M%P")).append(")");
                Log.d(TAG, msg.toString());
            }
        }
        if (eventIdsForQuery.charAt(eventIdsForQuery.length() - 1) == ',') {
            eventIdsForQuery.deleteCharAt(eventIdsForQuery.length() - 1);
        }
        eventIdsForQuery.append(')');

        // Query the reminders table for the events found.
        Cursor cursor = null;
        try {
            cursor = contentResolver.query(Reminders.CONTENT_URI, REMINDERS_PROJECTION,
                    REMINDERS_WHERE + eventIdsForQuery, null, null);

            // Process the reminders query results to find the next reminder time.
            cursor.moveToPosition(-1);
            while (cursor.moveToNext()) {
                int eventId = cursor.getInt(REMINDERS_INDEX_EVENT_ID);
                int reminderMinutes = cursor.getInt(REMINDERS_INDEX_MINUTES);
                List<Long> startTimes = eventMap.get(eventId);
                if (startTimes != null) {
                    for (Long startTime : startTimes) {
                        long alarmTime = startTime - reminderMinutes * DateUtils.MINUTE_IN_MILLIS;
                        if (alarmTime > currentMillis && alarmTime < nextAlarmTime) {
                            nextAlarmTime = alarmTime;
                            nextAlarmEventId = eventId;
                        }

                        if (Log.isLoggable(TAG, Log.DEBUG)) {
                            timeObj.set(alarmTime);
                            StringBuilder msg = new StringBuilder();
                            msg.append("Reminders cursor result -- eventId:").append(eventId);
                            msg.append(", startTime:").append(startTime);
                            msg.append(", minutes:").append(reminderMinutes);
                            msg.append(", alarmTime:").append(alarmTime);
                            msg.append(" (").append(timeObj.format("%a, %b %d, %Y %I:%M%P")).append(")");
                            Log.d(TAG, msg.toString());
                        }
                    }
                }
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }

    // Schedule the alarm for the next reminder time.
    if (nextAlarmTime < Long.MAX_VALUE) {
        scheduleAlarm(context, nextAlarmEventId, nextAlarmTime, currentMillis, alarmManager);
    }
}

From source file:com.android.car.trust.CarBleTrustAgent.java

private void unlock(byte[] token, long handle) {
    UserManager um = (UserManager) getSystemService(Context.USER_SERVICE);

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "About to unlock user. Current handle: " + handle + " Time: " + System.currentTimeMillis());
    }//  w  w  w .java  2  s.  c o  m
    unlockUserWithToken(handle, token, getCurrentUserHandle());

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Attempted to unlock user, is user unlocked? " + um.isUserUnlocked() + " Time: "
                + System.currentTimeMillis());
    }
    setManagingTrust(true);

    if (um.isUserUnlocked()) {
        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, getString(R.string.trust_granted_explanation));
        }
        grantTrust("Granting trust from escrow token", TRUST_DURATION_MS, FLAG_GRANT_TRUST_DISMISS_KEYGUARD);
        // Trust has been granted, disable the BLE server. This trust agent service does
        // not need to receive additional BLE data.
        unbindService(mServiceConnection);
    }
}

From source file:com.example.android.wearable.agendadata.MainActivity.java

@Override
public void onConnected(Bundle connectionHint) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "Connected to Google Api Service.");
    }//from   ww  w.  j ava  2  s  . co  m
    mResolvingError = false;
}

From source file:com.yxkang.android.percent.PercentLayoutHelper.java

/**
 * Constructs a PercentLayoutInfo from attributes associated with a View. Call this method from
 * {@code LayoutParams(Context c, AttributeSet attrs)} constructor.
 *
 * @param context Context/* ww  w. j  a  v a  2 s . co m*/
 * @param attrs   AttributeSet
 * @return PercentLayoutInfo
 */
public static PercentLayoutInfo getPercentLayoutInfo(Context context, AttributeSet attrs) {
    PercentLayoutInfo info = null;
    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.PercentLayout_Layout);
    float value = array.getFraction(R.styleable.PercentLayout_Layout_layout_widthPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent width: " + value);
        }
        info = new PercentLayoutInfo();
        info.widthPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_heightPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent height: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.heightPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.leftMarginPercent = value;
        info.topMarginPercent = value;
        info.rightMarginPercent = value;
        info.bottomMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginLeftPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent left margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.leftMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginTopPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent top margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.topMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginRightPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent right margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.rightMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginBottomPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent bottom margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.bottomMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginStartPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent start margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.startMarginPercent = value;
    }
    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_marginEndPercent, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "percent end margin: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.endMarginPercent = value;
    }

    value = array.getFraction(R.styleable.PercentLayout_Layout_layout_aspectRatio, 1, 1, -1f);
    if (value != -1f) {
        if (Log.isLoggable(TAG, Log.VERBOSE)) {
            Log.v(TAG, "aspect ratio: " + value);
        }
        info = info != null ? info : new PercentLayoutInfo();
        info.aspectRatio = value;
    }

    array.recycle();
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "constructed: " + info);
    }
    return info;
}

From source file:com.spark.percent.PercentLayoutHelper.java

private void invokeMethod(String methodName, int widthHint, int heightHint, View view, Class<?> clazz,
        PercentLayoutInfo.PercentVal percentVal)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    if (Log.isLoggable(TAG, Log.DEBUG))
        Log.d(TAG, methodName + " ==> " + percentVal);
    if (percentVal != null) {
        Method setMaxWidthMethod = clazz.getMethod(methodName, int.class);
        setMaxWidthMethod.setAccessible(true);
        int base = getBaseByModeAndVal(widthHint, heightHint, percentVal.basemode);
        setMaxWidthMethod.invoke(view, (int) (base * percentVal.percent));
    }/*from w  ww . ja v  a 2 s.  c o  m*/
}

From source file:com.google.android.car.kitchensink.radio.RadioTestFragment.java

private void initializeRadio() {
    mRadioManager = (RadioManager) getContext().getSystemService(Context.RADIO_SERVICE);

    if (mRadioManager == null) {
        throw new IllegalStateException("RadioManager could not be loaded.");
    }//w w w . j a  va2 s .  co m

    int status = mRadioManager.listModules(mModules);
    if (status != RadioManager.STATUS_OK) {
        throw new IllegalStateException("Load modules failed with status: " + status);
    }

    if (mModules.size() == 0) {
        throw new IllegalStateException("No radio modules on device.");
    }

    boolean isDebugLoggable = Log.isLoggable(TAG, Log.DEBUG);

    // Load the possible radio bands. For now, just accept FM and AM bands.
    for (RadioManager.BandDescriptor band : mModules.get(0).getBands()) {
        if (isDebugLoggable) {
            Log.d(TAG, "loading band: " + band.toString());
        }

        if (mFmDescriptor == null && band.isFmBand()) {
            mFmDescriptor = (RadioManager.FmBandDescriptor) band;
        }

        if (mAmDescriptor == null && band.isAmBand()) {
            mAmDescriptor = (RadioManager.AmBandDescriptor) band;
        }
    }

    if (mFmDescriptor == null && mAmDescriptor == null) {
        throw new IllegalStateException("No AM and FM radio bands could be loaded.");
    }

    mFmConfig = new RadioManager.FmBandConfig.Builder(mFmDescriptor).setStereo(true).build();
    mAmConfig = new RadioManager.AmBandConfig.Builder(mAmDescriptor).setStereo(true).build();
}

From source file:com.example.android.wearable.agendadata.MainActivity.java

@Override
public void onConnectionSuspended(int cause) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onConnectionSuspended(): Cause id: " + cause);
    }/*from   w ww.j  a  va 2 s.co  m*/
}