Java Code Examples for com.example.android.common.logger.Log#i()

The following examples show how to use com.example.android.common.logger.Log#i() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From android-ClippingBasic with Apache License 2.0 6 votes vote down vote up
/** 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");
}
 
Example 2
Source File: MainActivity.java    From connectivity-samples with Apache License 2.0 6 votes vote down vote up
/**
 * 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");
}
 
Example 3
Source File: ScreenCaptureFragment.java    From android-ScreenCapture with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_MEDIA_PROJECTION) {
        if (resultCode != Activity.RESULT_OK) {
            Log.i(TAG, "User cancelled");
            Toast.makeText(getActivity(), R.string.user_cancelled, Toast.LENGTH_SHORT).show();
            return;
        }
        Activity activity = getActivity();
        if (activity == null) {
            return;
        }
        Log.i(TAG, "Starting screen capture");
        mResultCode = resultCode;
        mResultData = data;
        setUpMediaProjection();
        setUpVirtualDisplay();
    }
}
 
Example 4
Source File: MainActivity.java    From animation-samples with Apache License 2.0 6 votes vote down vote up
/** 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");
}
 
Example 5
Source File: StorageClientFragment.java    From storage-samples with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(int requestCode, int resultCode, Intent resultData) {
    Log.i(TAG, "Received an \"Activity Result\"");
    // BEGIN_INCLUDE (parse_open_document_response)
    // The ACTION_OPEN_DOCUMENT intent was sent with the request code READ_REQUEST_CODE.
    // If the request code seen here doesn't match, it's the response to some other intent,
    // and the below code shouldn't run at all.

    if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        // The document selected by the user won't be returned in the intent.
        // Instead, a URI to that document will be contained in the return intent
        // provided to this method as a parameter.  Pull that uri using "resultData.getData()"
        Uri uri = null;
        if (resultData != null) {
            uri = resultData.getData();
            Log.i(TAG, "Uri: " + uri.toString());
            showImage(uri);
        }
        // END_INCLUDE (parse_open_document_response)
    }
}
 
Example 6
Source File: MainActivity.java    From android-play-places with Apache License 2.0 5 votes vote down vote up
@Override
public void onComplete(Task<PlaceBufferResponse> task) {
    try {
        PlaceBufferResponse places = task.getResult();

        // Get the Place object from the buffer.
        final Place place = places.get(0);

        // Format details of the place for display and show it in a TextView.
        mPlaceDetailsText.setText(formatPlaceDetails(getResources(), place.getName(),
                place.getId(), place.getAddress(), place.getPhoneNumber(),
                place.getWebsiteUri()));

        // Display the third party attributions if set.
        final CharSequence thirdPartyAttribution = places.getAttributions();
        if (thirdPartyAttribution == null) {
            mPlaceDetailsAttribution.setVisibility(View.GONE);
        } else {
            mPlaceDetailsAttribution.setVisibility(View.VISIBLE);
            mPlaceDetailsAttribution.setText(
                    Html.fromHtml(thirdPartyAttribution.toString()));
        }

        Log.i(TAG, "Place details received: " + place.getName());

        places.release();
    } catch (RuntimeRemoteException e) {
        // Request did not complete successfully
        Log.e(TAG, "Place query did not complete.", e);
        return;
    }
}
 
Example 7
Source File: SampleActivityBase.java    From android-RepeatingAlarm with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 8
Source File: SampleActivityBase.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 9
Source File: SampleActivityBase.java    From user-interface-samples with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 10
Source File: SampleActivityBase.java    From views-widgets-samples with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 11
Source File: SampleActivityBase.java    From android-SlidingTabsColors with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 12
Source File: SampleActivityBase.java    From android-play-safetynet with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 13
Source File: SwipeRefreshMultipleViewsFragment.java    From android-SwipeRefreshMultipleViews with Apache License 2.0 5 votes vote down vote up
/**
 * By abstracting the refresh process to a single method, the app allows both the
 * SwipeGestureLayout onRefresh() method and the Refresh action item to refresh the content.
 */
private void initiateRefresh() {
    Log.i(LOG_TAG, "initiateRefresh");

    /**
     * Execute the background task, which uses {@link android.os.AsyncTask} to load the data.
     */
    new DummyBackgroundTask().execute();
}
 
Example 14
Source File: MyCloudProvider.java    From storage-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteDocument(String documentId) throws FileNotFoundException {
    Log.v(TAG, "deleteDocument");
    File file = getFileForDocId(documentId);
    if (file.delete()) {
        Log.i(TAG, "Deleted file with id " + documentId);
    } else {
        throw new FileNotFoundException("Failed to delete document with id " + documentId);
    }
}
 
Example 15
Source File: AdvancedImmersiveModeFragment.java    From android-AdvancedImmersiveMode with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to dump flag state to the log.
 * @param uiFlags Set of UI flags to inspect
 */
public void dumpFlagStateToLog(int uiFlags) {
    if ((uiFlags & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
        Log.i(TAG, "SYSTEM_UI_FLAG_LOW_PROFILE is set");
    } else {
        Log.i(TAG, "SYSTEM_UI_FLAG_LOW_PROFILE is unset");
    }

    if ((uiFlags & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0) {
        Log.i(TAG, "SYSTEM_UI_FLAG_FULLSCREEN is set");
    } else {
        Log.i(TAG, "SYSTEM_UI_FLAG_FULLSCREEN is unset");
    }

    if ((uiFlags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0) {
        Log.i(TAG, "SYSTEM_UI_FLAG_HIDE_NAVIGATION is set");
    } else {
        Log.i(TAG, "SYSTEM_UI_FLAG_HIDE_NAVIGATION is unset");
    }

    if ((uiFlags & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0) {
        Log.i(TAG, "SYSTEM_UI_FLAG_IMMERSIVE is set");
    } else {
        Log.i(TAG, "SYSTEM_UI_FLAG_IMMERSIVE is unset");
    }

    if ((uiFlags & View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) != 0) {
        Log.i(TAG, "SYSTEM_UI_FLAG_IMMERSIVE_STICKY is set");
    } else {
        Log.i(TAG, "SYSTEM_UI_FLAG_IMMERSIVE_STICKY is unset");
    }
}
 
Example 16
Source File: BasicImmersiveModeFragment.java    From android-BasicImmersiveMode with Apache License 2.0 5 votes vote down vote up
/**
 * Detects and toggles immersive mode.
 */
public void toggleHideyBar() {
    // BEGIN_INCLUDE (get_current_ui_flags)
    // The UI options currently enabled are represented by a bitfield.
    // getSystemUiVisibility() gives us that bitfield.
    int uiOptions = getActivity().getWindow().getDecorView().getSystemUiVisibility();
    int newUiOptions = uiOptions;
    // END_INCLUDE (get_current_ui_flags)
    // BEGIN_INCLUDE (toggle_ui_flags)
    boolean isImmersiveModeEnabled =
            ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
    if (isImmersiveModeEnabled) {
        Log.i(TAG, "Turning immersive mode mode off. ");
    } else {
        Log.i(TAG, "Turning immersive mode mode on.");
    }

    // Immersive mode: Backward compatible to KitKat (API 19).
    // Note that this flag doesn't do anything by itself, it only augments the behavior
    // of HIDE_NAVIGATION and FLAG_FULLSCREEN.  For the purposes of this sample
    // all three flags are being toggled together.
    // This sample uses the "sticky" form of immersive mode, which will let the user swipe
    // the bars back in again, but will automatically make them disappear a few seconds later.
    newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
    newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
    newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
    getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
    //END_INCLUDE (set_ui_flags)
}
 
Example 17
Source File: SampleActivityBase.java    From android-MediaEffects with Apache License 2.0 5 votes vote down vote up
/** 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");
}
 
Example 18
Source File: BatchStepSensorFragment.java    From android-BatchStepSensor with Apache License 2.0 4 votes vote down vote up
/**
 * Register a {@link android.hardware.SensorEventListener} for the sensor and max batch delay.
 * The maximum batch delay specifies the maximum duration in microseconds for which subsequent
 * sensor events can be temporarily stored by the sensor before they are delivered to the
 * registered SensorEventListener. A larger delay allows the system to handle sensor events more
 * efficiently, allowing the system to switch to a lower power state while the sensor is
 * capturing events. Once the max delay is reached, all stored events are delivered to the
 * registered listener. Note that this value only specifies the maximum delay, the listener may
 * receive events quicker. A delay of 0 disables batch mode and registers the listener in
 * continuous mode.
 * The optimium batch delay depends on the application. For example, a delay of 5 seconds or
 * higher may be appropriate for an  application that does not update the UI in real time.
 *
 * @param maxdelay
 * @param sensorType
 */
private void registerEventListener(int maxdelay, int sensorType) {
    // BEGIN_INCLUDE(register)

    // Keep track of state so that the correct sensor type and batch delay can be set up when
    // the app is restored (for example on screen rotation).
    mMaxDelay = maxdelay;
    if (sensorType == Sensor.TYPE_STEP_COUNTER) {
        mState = STATE_COUNTER;
        /*
        Reset the initial step counter value, the first event received by the event listener is
        stored in mCounterSteps and used to calculate the total number of steps taken.
         */
        mCounterSteps = 0;
        Log.i(TAG, "Event listener for step counter sensor registered with a max delay of "
                + mMaxDelay);
    } else {
        mState = STATE_DETECTOR;
        Log.i(TAG, "Event listener for step detector sensor registered with a max delay of "
                + mMaxDelay);
    }

    // Get the default sensor for the sensor type from the SenorManager
    SensorManager sensorManager =
            (SensorManager) getActivity().getSystemService(Activity.SENSOR_SERVICE);
    // sensorType is either Sensor.TYPE_STEP_COUNTER or Sensor.TYPE_STEP_DETECTOR
    Sensor sensor = sensorManager.getDefaultSensor(sensorType);

    // Register the listener for this sensor in batch mode.
    // If the max delay is 0, events will be delivered in continuous mode without batching.
    final boolean batchMode = sensorManager.registerListener(
            mListener, sensor, SensorManager.SENSOR_DELAY_NORMAL, maxdelay);

    if (!batchMode) {
        // Batch mode could not be enabled, show a warning message and switch to continuous mode
        getCardStream().getCard(CARD_NOBATCHSUPPORT)
                .setDescription(getString(R.string.warning_nobatching));
        getCardStream().showCard(CARD_NOBATCHSUPPORT);
        Log.w(TAG, "Could not register sensor listener in batch mode, " +
                "falling back to continuous mode.");
    }

    if (maxdelay > 0 && batchMode) {
        // Batch mode was enabled successfully, show a description card
        getCardStream().showCard(CARD_BATCHING_DESCRIPTION);
    }

    // Show the explanation card
    getCardStream().showCard(CARD_EXPLANATION);

    // END_INCLUDE(register)

}
 
Example 19
Source File: StorageClientFragment.java    From storage-samples with Apache License 2.0 4 votes vote down vote up
/**
 * Grabs metadata for a document specified by URI, logs it to the screen.
 *
 * @param uri The uri for the document whose metadata should be printed.
 */
public void dumpImageMetaData(Uri uri) {
    // BEGIN_INCLUDE (dump_metadata)

    // The query, since it only applies to a single document, will only return one row.
    // no need to filter, sort, or select fields, since we want all fields for one
    // document.
    Cursor cursor = getActivity().getContentResolver()
            .query(uri, null, null, null, null, null);

    try {
        // moveToFirst() returns false if the cursor has 0 rows.  Very handy for
        // "if there's anything to look at, look at it" conditionals.
        if (cursor != null && cursor.moveToFirst()) {

            // Note it's called "Display Name".  This is provider-specific, and
            // might not necessarily be the file name.
            String displayName = cursor.getString(
                    cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
            Log.i(TAG, "Display Name: " + displayName);

            int sizeIndex = cursor.getColumnIndex(OpenableColumns.SIZE);
            // If the size is unknown, the value stored is null.  But since an int can't be
            // null in java, the behavior is implementation-specific, which is just a fancy
            // term for "unpredictable".  So as a rule, check if it's null before assigning
            // to an int.  This will happen often:  The storage API allows for remote
            // files, whose size might not be locally known.
            String size = null;
            if (!cursor.isNull(sizeIndex)) {
                // Technically the column stores an int, but cursor.getString will do the
                // conversion automatically.
                size = cursor.getString(sizeIndex);
            } else {
                size = "Unknown";
            }
            Log.i(TAG, "Size: " + size);
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    // END_INCLUDE (dump_metadata)
}
 
Example 20
Source File: GestureListener.java    From android-BasicGestureDetect with Apache License 2.0 4 votes vote down vote up
@Override
public boolean onDown(MotionEvent e) {
    // "Down" event - User touched the screen.
    Log.i(TAG, "Down" + getTouchType(e));
    return false;
}