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.android.car.trust.CarBleTrustAgent.java

@Override
public void onEscrowTokenAdded(byte[] token, long handle, UserHandle user) {
    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onEscrowTokenAdded, handle: " + handle);
    }//from w w w  .  ja  v  a2 s  . c  o m

    Intent intent = new Intent();
    intent.setAction(ACTION_ADD_TOKEN_RESULT);
    intent.putExtra(INTENT_EXTRA_TOKEN_HANDLE, handle);

    mLocalBroadcastManager.sendBroadcast(intent);
}

From source file:de.madvertise.android.sdk.MadvertiseUtil.java

/**
 * Try to update current location. Non blocking call.
 * // w  w  w  . j a v  a 2  s . c  o m
 * @param context
 *            application context
 */
public static void refreshCoordinates(final Context context) {
    MadvertiseUtil.logMessage(null, Log.DEBUG, "Trying to refresh location");

    if (context == null) {
        MadvertiseUtil.logMessage(null, Log.DEBUG, "Context not set - quit location refresh");
        return;
    }

    // check if we need a regular update
    if ((sLocationUpdateTimestamp + MadvertiseUtil.SECONDS_TO_REFRESH_LOCATION * 1000) > System
            .currentTimeMillis()) {
        MadvertiseUtil.logMessage(null, Log.DEBUG, "It's not time yet for refreshing the location");
        return;
    }

    synchronized (context) {
        // recheck, if location was updated by another thread while we
        // paused
        if ((sLocationUpdateTimestamp + MadvertiseUtil.SECONDS_TO_REFRESH_LOCATION * 1000) > System
                .currentTimeMillis()) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "Another thread updated the loation already");
            return;
        }

        boolean permissionCoarseLocation = MadvertiseUtil
                .checkPermissionGranted(android.Manifest.permission.ACCESS_COARSE_LOCATION, context);
        boolean permissionFineLocation = MadvertiseUtil
                .checkPermissionGranted(android.Manifest.permission.ACCESS_FINE_LOCATION, context);

        // return (null) if we do not have any permissions
        if (!permissionCoarseLocation && !permissionFineLocation) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "No permissions for requesting the location");
            return;
        }

        // return (null) if we can't get a location manager
        LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
        if (locationManager == null) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "Unable to fetch a location manger");
            return;
        }

        String provider = null;
        Criteria criteria = new Criteria();
        criteria.setCostAllowed(false);

        // try to get coarse location first
        if (permissionCoarseLocation) {
            criteria.setAccuracy(Criteria.ACCURACY_COARSE);
            provider = locationManager.getBestProvider(criteria, true);
        }

        // try to get gps location if coarse locatio did not work
        if (provider == null && permissionFineLocation) {
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            provider = locationManager.getBestProvider(criteria, true);
        }

        // still no provider, return (null)
        if (provider == null) {
            MadvertiseUtil.logMessage(null, Log.DEBUG, "Unable to fetch a location provider");
            return;
        }

        // create a finalized reference to the location manager, in order to
        // access it in the inner class
        final LocationManager finalizedLocationManager = locationManager;
        sLocationUpdateTimestamp = System.currentTimeMillis();
        locationManager.requestLocationUpdates(provider, 0, 0, new LocationListener() {
            @Override
            public void onLocationChanged(Location location) {
                MadvertiseUtil.logMessage(null, Log.DEBUG, "Refreshing location");
                sCurrentLocation = location;
                sLocationUpdateTimestamp = System.currentTimeMillis();
                // stop draining battery life
                finalizedLocationManager.removeUpdates(this);
            }

            // not used yet
            @Override
            public void onProviderDisabled(String provider) {
            }

            @Override
            public void onProviderEnabled(String provider) {
            }

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) {
            }
        }, context.getMainLooper());
    }
}

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

@Override
public void onGyroscopeUpdate(MotionSensor sensor, MotionReading reading) {
    Message m = mHandler.obtainMessage(MessageConstants.MESSAGE_GYROSCOPE_READING);
    Bundle b = m.getData();/*ww w  . ja va 2s .  com*/
    b.putFloat(MessageConstants.X_VALUE_KEY, (reading.getX() + 2000) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Y_VALUE_KEY, (reading.getY() + 2000) * DECIMAL_PRECISION);
    b.putFloat(MessageConstants.Z_VALUE_KEY, (reading.getZ() + 2000) * 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 = "gyroscope;" + 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.example.android.wearable.agendadata.MainActivity.java

/**
 * Callback received when a permissions request has been completed.
 *//*  w w  w . j  a v a  2s.  c om*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
        @NonNull int[] grantResults) {

    if (Log.isLoggable(TAG, Log.DEBUG)) {
        Log.d(TAG, "onRequestPermissionsResult(): " + permissions);
    }

    if (requestCode == REQUEST_CALENDAR_AND_CONTACTS) {
        // BEGIN_INCLUDE(permissions_result)
        // Received permission result for calendar permission.
        Log.i(TAG, "Received response for Calendar permission request.");

        // Check if all required permissions have been granted.
        if ((grantResults.length == 2) && (grantResults[0] == PackageManager.PERMISSION_GRANTED)
                && (grantResults[1] == PackageManager.PERMISSION_GRANTED)) {
            // Calendar/Contact permissions have been granted, pull all calendar events
            Log.i(TAG, "All permission has now been granted. Showing preview.");
            Snackbar.make(mLayout, R.string.permisions_granted, Snackbar.LENGTH_SHORT).show();

            pushCalendarToWear();

        } else {
            Log.i(TAG, "CALENDAR and/or CONTACT permissions were NOT granted.");
            Snackbar.make(mLayout, R.string.permissions_denied, Snackbar.LENGTH_SHORT).show();
        }
        // END_INCLUDE(permissions_result)

    } else {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}

From source file:com.loopj.android.http.RdHttpClient.java

/**
 * /*w w w. j av a2  s.c o  m*/
 * 
 * @param url
 * @param params
 * @return
 * @throws Exception
 */
public String get(String url, RequestParams params) throws Exception {

    if (!Utils.checkNetworkAvailable(MyOwnMVCApp.app)) {
        throw new Exception(MyOwnMVCApp.app.getString(R.string.no_network));
    }
    String furl = getUrlWithQueryString(url, params);

    MyLog.log(Log.DEBUG, getClass(), "block get:" + furl);

    RdHttpRequest request = new RdHttpRequest(httpClient, httpContext, new HttpGet(furl));
    String res = request.run();
    MyLog.log(Log.DEBUG, getClass(), "block get:" + furl + " res:" + res);
    return res;
}

From source file:com.android.mms.ui.ConversationListItem.java

public final void unbind() {
    if (Log.isLoggable(LogTag.CONTACT, Log.DEBUG)) {
        Log.v(TAG, "unbind: contacts.removeListeners " + this);
    }/*w w w  . ja v a2s . c o m*/
    // Unregister contact update callbacks.
    Contact.removeListener(this);
}

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

private void http_thread() {
    try {/* w ww. ja  v a2  s  . c o m*/
        mThread.setName("http-stream-thread");
        int port = (mURI.getPort() != -1) ? mURI.getPort() : (mURI.getProtocol().equals("https") ? 443 : 80);

        String path = TextUtils.isEmpty(mURI.getPath()) ? "/" : mURI.getPath();
        if (!TextUtils.isEmpty(mURI.getQuery())) {
            path += "?" + mURI.getQuery();
        }

        PrintWriter out = new PrintWriter(mSocket.getOutputStream());

        if (mProxyHost != null && mProxyHost.length() > 0 && mProxyPort > 0) {
            out.print("CONNECT " + mURI.getHost() + ":" + port + " HTTP/1.0\r\n");
            out.print("\r\n");
            out.flush();
            HybiParser.HappyDataInputStream stream = new HybiParser.HappyDataInputStream(
                    mSocket.getInputStream());

            // Read HTTP response status line.
            StatusLine statusLine = parseStatusLine(readLine(stream));
            if (statusLine == null) {
                throw new HttpException("Received no reply from server.");
            } else if (statusLine.getStatusCode() != HttpStatus.SC_OK) {
                throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
            }

            // Read HTTP response headers.
            while (!TextUtils.isEmpty(readLine(stream)))
                ;
            if (mURI.getProtocol().equals("https")) {
                mSocket = getSSLSocketFactory().createSocket(mSocket, mURI.getHost(), port, false);
                SSLSocket s = (SSLSocket) mSocket;
                try {
                    s.setEnabledProtocols(ENABLED_PROTOCOLS);
                } catch (IllegalArgumentException e) {
                    //Not supported on older Android versions
                }
                try {
                    s.setEnabledCipherSuites(ENABLED_CIPHERS);
                } catch (IllegalArgumentException e) {
                    //Not supported on older Android versions
                }
                out = new PrintWriter(mSocket.getOutputStream());
            }
        }

        if (mURI.getProtocol().equals("https")) {
            SSLSocket s = (SSLSocket) mSocket;
            StrictHostnameVerifier verifier = new StrictHostnameVerifier();
            if (!verifier.verify(mURI.getHost(), s.getSession()))
                throw new SSLException("Hostname mismatch");
        }

        Crashlytics.log(Log.DEBUG, TAG, "Sending HTTP request");

        out.print("GET " + path + " HTTP/1.0\r\n");
        out.print("Host: " + mURI.getHost() + "\r\n");
        if (mURI.getHost().equals(NetworkConnection.IRCCLOUD_HOST)
                && NetworkConnection.getInstance().session != null
                && NetworkConnection.getInstance().session.length() > 0)
            out.print("Cookie: session=" + NetworkConnection.getInstance().session + "\r\n");
        out.print("Connection: close\r\n");
        out.print("Accept-Encoding: gzip\r\n");
        out.print("User-Agent: " + NetworkConnection.getInstance().useragent + "\r\n");
        out.print("\r\n");
        out.flush();

        HybiParser.HappyDataInputStream stream = new HybiParser.HappyDataInputStream(mSocket.getInputStream());

        // Read HTTP response status line.
        StatusLine statusLine = parseStatusLine(readLine(stream));
        if (statusLine != null)
            Crashlytics.log(Log.DEBUG, TAG, "Got HTTP response: " + statusLine);

        if (statusLine == null) {
            throw new HttpException("Received no reply from server.");
        } else if (statusLine.getStatusCode() != HttpStatus.SC_OK
                && statusLine.getStatusCode() != HttpStatus.SC_MOVED_PERMANENTLY) {
            Crashlytics.log(Log.ERROR, TAG, "Failure: " + mURI + ": " + statusLine.getStatusCode() + " "
                    + statusLine.getReasonPhrase());
            throw new HttpResponseException(statusLine.getStatusCode(), statusLine.getReasonPhrase());
        }

        // Read HTTP response headers.
        String line;

        boolean gzipped = false;
        while (!TextUtils.isEmpty(line = readLine(stream))) {
            Header header = parseHeader(line);
            if (header.getName().equalsIgnoreCase("content-encoding")
                    && header.getValue().equalsIgnoreCase("gzip"))
                gzipped = true;
            if (statusLine.getStatusCode() == HttpStatus.SC_MOVED_PERMANENTLY
                    && header.getName().equalsIgnoreCase("location")) {
                Crashlytics.log(Log.INFO, TAG, "Redirecting to: " + header.getValue());
                mURI = new URL(header.getValue());
                mSocket.close();
                mSocket = null;
                mThread = null;
                connect();
                return;
            }
        }

        if (gzipped)
            onStreamConnected(new GZIPInputStream(mSocket.getInputStream()));
        else
            onStreamConnected(mSocket.getInputStream());

        onFetchComplete();
    } catch (Exception ex) {
        NetworkConnection.printStackTraceToCrashlytics(ex);
        onFetchFailed();
    }
}

From source file:com.radicaldynamic.groupinform.services.DatabaseService.java

synchronized public ReplicationStatus replicate(String db, int mode) {
    final String tt = t + "replicate(): ";

    if (Collect.Log.DEBUG)
        Log.d(Collect.LOGTAG, tt + "about to replicate " + db);

    // Will not replicate unless signed in
    if (!Collect.getInstance().getIoService().isSignedIn()) {
        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, tt + "aborting replication: not signed in");
        return null;
    }/*from   w w w .j  a  v  a  2 s .  c  om*/

    if (Collect.getInstance().getInformOnlineState().isOfflineModeEnabled()) {
        if (Collect.Log.DEBUG)
            Log.d(Collect.LOGTAG, tt + "aborting replication: offline mode is enabled");
        return null;
    }

    /*
     * Lookup master cluster by IP.  Do this instead of relying on Erlang's internal resolver 
     * (and thus Google's public DNS).  Our builds of Erlang for Android do not yet use 
     * Android's native DNS resolver.
     */
    String masterClusterIP = null;

    try {
        InetAddress[] clusterInetAddresses = InetAddress
                .getAllByName(getString(R.string.tf_default_ionline_server));
        masterClusterIP = clusterInetAddresses[new Random().nextInt(clusterInetAddresses.length)]
                .getHostAddress();
    } catch (UnknownHostException e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "unable to lookup master cluster IP addresses: " + e.toString());
        e.printStackTrace();
    }

    // Create local instance of database
    boolean dbCreated = false;

    // User may not have connected to local database yet - start up the connection for them
    try {
        if (mLocalDbInstance == null) {
            connectToLocalServer();
        }
    } catch (DbUnavailableException e) {
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, tt + "cannot connect to local database server");
        e.printStackTrace();
    }

    if (mLocalDbInstance.getAllDatabases().indexOf("db_" + db) == -1) {
        switch (mode) {
        case REPLICATE_PULL:
            if (Collect.Log.INFO)
                Log.i(Collect.LOGTAG, tt + "creating local database " + db);
            mLocalDbInstance.createDatabase("db_" + db);
            dbCreated = true;
            break;

        case REPLICATE_PUSH:
            // If the database does not exist client side then there is no point in continuing
            if (Collect.Log.WARN)
                Log.w(Collect.LOGTAG, tt + "cannot find local database " + db + " to push");
            return null;
        }
    }

    // Configure replication direction
    String source = null;
    String target = null;

    String deviceId = Collect.getInstance().getInformOnlineState().getDeviceId();
    String deviceKey = Collect.getInstance().getInformOnlineState().getDeviceKey();

    String localServer = "http://" + mLocalHost + ":" + mLocalPort + "/db_" + db;
    String remoteServer = "http://" + deviceId + ":" + deviceKey + "@" + masterClusterIP + ":5984/db_" + db;

    // Should we use encrypted transfers?
    SharedPreferences settings = PreferenceManager
            .getDefaultSharedPreferences(Collect.getInstance().getBaseContext());

    if (settings.getBoolean(PreferencesActivity.KEY_ENCRYPT_SYNCHRONIZATION, true)) {
        remoteServer = "https://" + deviceId + ":" + deviceKey + "@" + masterClusterIP + ":6984/db_" + db;
    }

    switch (mode) {
    case REPLICATE_PUSH:
        source = localServer;
        target = remoteServer;
        break;

    case REPLICATE_PULL:
        source = remoteServer;
        target = localServer;
        break;
    }

    ReplicationCommand cmd = new ReplicationCommand.Builder().source(source).target(target).build();
    ReplicationStatus status = null;

    try {
        status = mLocalDbInstance.replicate(cmd);
    } catch (Exception e) {
        // Remove a recently created DB if the replication failed
        if (dbCreated) {
            if (Collect.Log.ERROR)
                Log.e(Collect.LOGTAG, t + "replication exception: " + e.toString());
            e.printStackTrace();

            mLocalDbInstance.deleteDatabase("db_" + db);
        }
    }

    return status;
}

From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java

private boolean checkout() {
    boolean saidGoodbye = false;

    String checkoutUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/checkout";
    String getResult = HttpUtils.getUrlData(checkoutUrl);
    JSONObject checkout;/*from   w ww. j  ava2s  . com*/

    try {
        checkout = (JSONObject) new JSONTokener(getResult).nextValue();

        String result = checkout.optString(InformOnlineState.RESULT, InformOnlineState.ERROR);

        if (result.equals(InformOnlineState.OK)) {
            if (Collect.Log.INFO)
                Log.i(Collect.LOGTAG, t + "said goodbye to Group Complete");
        } else {
            if (Collect.Log.DEBUG)
                Log.d(Collect.LOGTAG, t + "device checkout unnecessary");
        }

        saidGoodbye = true;
    } catch (NullPointerException e) {
        // Communication error
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, t + "no getResult to parse.  Communication error with node.js server?");
        e.printStackTrace();
    } catch (JSONException e) {
        // Parse error (malformed result)
        if (Collect.Log.ERROR)
            Log.e(Collect.LOGTAG, t + "failed to parse getResult " + getResult);
        e.printStackTrace();
    } finally {
        // Running a checkout ALWAYS "signs us out"
        mSignedIn = false;
    }

    Collect.getInstance().getInformOnlineState().setSession(null);

    return saidGoodbye;
}

From source file:com.geocine.mms.com.android.mms.transaction.HttpUtils.java

private static AndroidHttpClient createHttpClient(Context context) {
    String userAgent = MmsConfig.getUserAgent();
    AndroidHttpClient client = AndroidHttpClient.newInstance(userAgent, context);
    HttpParams params = client.getParams();
    HttpProtocolParams.setContentCharset(params, "UTF-8");

    // set the socket timeout
    int soTimeout = MmsConfig.getHttpSocketTimeout();

    if (Log.isLoggable(LogTag.TRANSACTION, Log.DEBUG)) {
        Log.d(TAG,//from  w w  w.j a v  a2 s  .c om
                "[HttpUtils] createHttpClient w/ socket timeout " + soTimeout + " ms, " + ", UA=" + userAgent);
    }
    HttpConnectionParams.setSoTimeout(params, soTimeout);
    return client;
}