android.provider.DocumentsContract.Root#com.example.android.common.logger.Log源码实例Demo

下面列出了android.provider.DocumentsContract.Root#com.example.android.common.logger.Log 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android-DisplayingBitmaps   文件: ImageFetcher.java
@Override
protected void closeCacheInternal() {
    super.closeCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null) {
            try {
                if (!mHttpDiskCache.isClosed()) {
                    mHttpDiskCache.close();
                    mHttpDiskCache = null;
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "HTTP cache closed");
                    }
                }
            } catch (IOException e) {
                Log.e(TAG, "closeCacheInternal - " + e);
            }
        }
    }
}
 
/**
 * Start the ConnectThread to initiate a connection to a remote device.
 *
 * @param device The BluetoothDevice to connect
 * @param secure Socket Security type - Secure (true) , Insecure (false)
 */
public synchronized void connect(BluetoothDevice device, boolean secure) {
    Log.d(TAG, "connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new ConnectThread(device, secure);
    mConnectThread.start();
    // Update UI title
    updateUserInterfaceTitle();
}
 
public AcceptThread(boolean secure) {
    BluetoothServerSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Create a new listening server socket
    try {
        if (secure) {
            tmp = mAdapter.listenUsingRfcommWithServiceRecord(NAME_SECURE,
                    MY_UUID_SECURE);
        } else {
            tmp = mAdapter.listenUsingInsecureRfcommWithServiceRecord(
                    NAME_INSECURE, MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "listen() failed", e);
    }
    mmServerSocket = tmp;
    mState = STATE_LISTEN;
}
 
源代码4 项目: android-DisplayingBitmaps   文件: ImageFetcher.java
@Override
protected void clearCacheInternal() {
    super.clearCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null && !mHttpDiskCache.isClosed()) {
            try {
                mHttpDiskCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "HTTP cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCacheInternal - " + e);
            }
            mHttpDiskCache = null;
            mHttpDiskCacheStarting = true;
            initHttpDiskCache();
        }
    }
}
 
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
public void run() {
    Log.i(TAG, "BEGIN mConnectedThread");
    byte[] buffer = new byte[1024];
    int bytes;

    // Keep listening to the InputStream while connected
    while (mState == STATE_CONNECTED) {
        try {
            // Read from the InputStream
            bytes = mmInStream.read(buffer);

            // Send the obtained bytes to the UI Activity
            mHandler.obtainMessage(Constants.MESSAGE_READ, bytes, -1, buffer)
                    .sendToTarget();
        } catch (IOException e) {
            Log.e(TAG, "disconnected", e);
            connectionLost();
            break;
        }
    }
}
 
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码8 项目: connectivity-samples   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());
    logFragment.getLogView().setTextAppearance(this, R.style.Log);
    logFragment.getLogView().setBackgroundColor(Color.WHITE);

    Log.i(TAG, "Ready");
}
 
源代码9 项目: views-widgets-samples   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码10 项目: graphics-samples   文件: ImageFetcher.java
@Override
protected void closeCacheInternal() {
    super.closeCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null) {
            try {
                if (!mHttpDiskCache.isClosed()) {
                    mHttpDiskCache.close();
                    mHttpDiskCache = null;
                    if (BuildConfig.DEBUG) {
                        Log.d(TAG, "HTTP cache closed");
                    }
                }
            } catch (IOException e) {
                Log.e(TAG, "closeCacheInternal - " + e);
            }
        }
    }
}
 
源代码11 项目: graphics-samples   文件: ImageFetcher.java
@Override
protected void clearCacheInternal() {
    super.clearCacheInternal();
    synchronized (mHttpDiskCacheLock) {
        if (mHttpDiskCache != null && !mHttpDiskCache.isClosed()) {
            try {
                mHttpDiskCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "HTTP cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCacheInternal - " + e);
            }
            mHttpDiskCache = null;
            mHttpDiskCacheStarting = true;
            initHttpDiskCache();
        }
    }
}
 
源代码12 项目: graphics-samples   文件: ImageCache.java
/**
 * Clears both the memory and disk cache associated with this ImageCache object. Note that
 * this includes disk access so this should not be executed on the main/UI thread.
 */
public void clearCache() {
    if (mMemoryCache != null) {
        mMemoryCache.evictAll();
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Memory cache cleared");
        }
    }

    synchronized (mDiskCacheLock) {
        mDiskCacheStarting = true;
        if (mDiskLruCache != null && !mDiskLruCache.isClosed()) {
            try {
                mDiskLruCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "Disk cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCache - " + e);
            }
            mDiskLruCache = null;
            initDiskCache();
        }
    }
}
 
/**
 * Start the ConnectThread to initiate a connection to a remote device.
 *
 * @param device The BluetoothDevice to connect
 * @param secure Socket Security type - Secure (true) , Insecure (false)
 */
public synchronized void connect(BluetoothDevice device, boolean secure) {
    Log.d(TAG, "connect to: " + device);

    // Cancel any thread attempting to make a connection
    if (mState == STATE_CONNECTING) {
        if (mConnectThread != null) {
            mConnectThread.cancel();
            mConnectThread = null;
        }
    }

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {
        mConnectedThread.cancel();
        mConnectedThread = null;
    }

    // Start the thread to connect with the given device
    mConnectThread = new ConnectThread(device, secure);
    mConnectThread.start();
    // Update UI title
    updateUserInterfaceTitle();
}
 
private void gatherAdminExtras(HashMap<String, String> values) {
    Properties props = new Properties();
    Set<String> keys = new HashSet<>(values.keySet());
    for (String key : keys) {
        if (key.startsWith("android.app.extra")) {
            continue;
        }
        props.put(key, values.get(key));
        values.remove(key);
    }
    StringWriter sw = new StringWriter();
    try{
        props.store(sw, "admin extras bundle");
        values.put(DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE,
                sw.toString());
        Log.d(TAG, "Admin extras bundle=" + values.get(
                DevicePolicyManager.EXTRA_PROVISIONING_ADMIN_EXTRAS_BUNDLE));
    } catch (IOException e) {
        Log.e(TAG, "Unable to build admin extras bundle");
    }
}
 
源代码15 项目: android-DisplayingBitmaps   文件: ImageWorker.java
/**
 * Once the image is processed, associates it to the imageView
 */
@Override
protected void onPostExecute(BitmapDrawable value) {
    //BEGIN_INCLUDE(complete_background_work)
    boolean success = false;
    // if cancel was called on this task or the "exit early" flag is set then we're done
    if (isCancelled() || mExitTasksEarly) {
        value = null;
    }

    final ImageView imageView = getAttachedImageView();
    if (value != null && imageView != null) {
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "onPostExecute - setting bitmap");
        }
        success = true;
        setImageDrawable(imageView, value);
    }
    if (mOnImageLoadedListener != null) {
        mOnImageLoadedListener.onImageLoaded(success);
    }
    //END_INCLUDE(complete_background_work)
}
 
源代码16 项目: views-widgets-samples   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码17 项目: android-CardReader   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码18 项目: android-play-places   文件: MainActivity.java
/**
 * Callback invoked when a place has been selected from the PlaceAutocompleteFragment.
 */
@Override
public void onPlaceSelected(Place place) {
    Log.i(TAG, "Place Selected: " + place.getName());

    // Format the returned place's details and display them in the TextView.
    mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(), place.getId(),
            place.getAddress(), place.getPhoneNumber(), place.getWebsiteUri()));

    CharSequence attributions = place.getAttributions();
    if (!TextUtils.isEmpty(attributions)) {
        mPlaceAttribution.setText(Html.fromHtml(attributions.toString()));
    } else {
        mPlaceAttribution.setText("");
    }
}
 
源代码19 项目: graphics-samples   文件: MainActivity.java
/**
 * Create a chain of targets that will receive log data
 */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码20 项目: android-play-safetynet   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());
    if (Build.VERSION.SDK_INT < 23) {
        //noinspection deprecation
        logFragment.getLogView().setTextAppearance(this, R.style.Log);
    } else {
        logFragment.getLogView().setTextAppearance(R.style.Log);
    }
    logFragment.getLogView().setBackgroundColor(Color.WHITE);

    Log.i(TAG, "Ready");
}
 
源代码21 项目: android-DisplayingBitmaps   文件: ImageCache.java
/**
 * Clears both the memory and disk cache associated with this ImageCache object. Note that
 * this includes disk access so this should not be executed on the main/UI thread.
 */
public void clearCache() {
    if (mMemoryCache != null) {
        mMemoryCache.evictAll();
        if (BuildConfig.DEBUG) {
            Log.d(TAG, "Memory cache cleared");
        }
    }

    synchronized (mDiskCacheLock) {
        mDiskCacheStarting = true;
        if (mDiskLruCache != null && !mDiskLruCache.isClosed()) {
            try {
                mDiskLruCache.delete();
                if (BuildConfig.DEBUG) {
                    Log.d(TAG, "Disk cache cleared");
                }
            } catch (IOException e) {
                Log.e(TAG, "clearCache - " + e);
            }
            mDiskLruCache = null;
            initDiskCache();
        }
    }
}
 
源代码22 项目: animation-samples   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码23 项目: animation-samples   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码24 项目: animation-samples   文件: MainActivity.java
/** Create a chain of targets that will receive log data */
@Override
public void initializeLogging() {
    // Wraps Android's native log framework.
    LogWrapper logWrapper = new LogWrapper();
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    Log.setLogNode(logWrapper);

    // Filter strips out everything except the message text.
    MessageOnlyLogFilter msgFilter = new MessageOnlyLogFilter();
    logWrapper.setNext(msgFilter);

    // On screen logging via a fragment with a TextView.
    LogFragment logFragment = (LogFragment) getSupportFragmentManager()
            .findFragmentById(R.id.log_fragment);
    msgFilter.setNext(logFragment.getLogView());

    Log.i(TAG, "Ready");
}
 
源代码25 项目: graphics-samples   文件: SampleActivityBase.java
/**
 * Set up targets to receive log data
 */
public void initializeLogging() {
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    // Wraps Android's native log framework
    LogWrapper logWrapper = new LogWrapper();
    Log.setLogNode(logWrapper);

    Log.i(TAG, "Ready");
}
 
/**
 * Unregisters the sensor listener if it is registered.
 */
private void unregisterListeners() {
    // BEGIN_INCLUDE(unregister)
    SensorManager sensorManager =
            (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE);
    sensorManager.unregisterListener(mListener);
    Log.i(TAG, "Sensor listener unregistered.");

    // END_INCLUDE(unregister)
}
 
private void sendSafetyNetRequest() {
    Log.i(TAG, "Sending SafetyNet API request.");

     /*
    Create a nonce for this request.
    The nonce is returned as part of the response from the
    SafetyNet API. Here we append the string to a number of random bytes to ensure it larger
    than the minimum 16 bytes required.
    Read out this value and verify it against the original request to ensure the
    response is correct and genuine.
    NOTE: A nonce must only be used once and a different nonce should be used for each request.
    As a more secure option, you can obtain a nonce from your own server using a secure
    connection. Here in this sample, we generate a String and append random bytes, which is not
    very secure. Follow the tips on the Security Tips page for more information:
    https://developer.android.com/training/articles/security-tips.html#Crypto
     */
    // TODO(developer): Change the nonce generation to include your own, used once value,
    // ideally from your remote server.
    String nonceData = "Safety Net Sample: " + System.currentTimeMillis();
    byte[] nonce = getRequestNonce(nonceData);

    /*
     Call the SafetyNet API asynchronously.
     The result is returned through the success or failure listeners.
     First, get a SafetyNetClient for the foreground Activity.
     Next, make the call to the attestation API. The API key is specified in the gradle build
     configuration and read from the gradle.properties file.
     */
    SafetyNetClient client = SafetyNet.getClient(getActivity());
    Task<SafetyNetApi.AttestationResponse> task = client.attest(nonce, BuildConfig.API_KEY);

    task.addOnSuccessListener(getActivity(), mSuccessListener)
            .addOnFailureListener(getActivity(), mFailureListener);

}
 
源代码28 项目: storage-samples   文件: MyCloudProvider.java
@Override
public Cursor queryDocument(String documentId, String[] projection)
        throws FileNotFoundException {
    Log.v(TAG, "queryDocument");

    // Create a cursor with the requested projection, or the default projection.
    final MatrixCursor result = new MatrixCursor(resolveDocumentProjection(projection));
    includeFile(result, documentId, null);
    return result;
}
 
/** Set up targets to receive log data */
public void initializeLogging() {
    // Using Log, front-end to the logging chain, emulates android.util.log method signatures.
    // Wraps Android's native log framework
    LogWrapper logWrapper = new LogWrapper();
    Log.setLogNode(logWrapper);

    Log.i(TAG, "Ready");
}
 
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case REQUEST_CONNECT_DEVICE_SECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, true);
            }
            break;
        case REQUEST_CONNECT_DEVICE_INSECURE:
            // When DeviceListActivity returns with a device to connect
            if (resultCode == Activity.RESULT_OK) {
                connectDevice(data, false);
            }
            break;
        case REQUEST_ENABLE_BT:
            // When the request to enable Bluetooth returns
            if (resultCode == Activity.RESULT_OK) {
                // Bluetooth is now enabled, so set up a chat session
                setupChat();
            } else {
                // User did not enable Bluetooth or an error occurred
                Log.d(TAG, "BT not enabled");
                FragmentActivity activity = getActivity();
                if (activity != null) {
                    Toast.makeText(activity, R.string.bt_not_enabled_leaving,
                            Toast.LENGTH_SHORT).show();
                    activity.finish();
                }
            }
    }
}