Example usage for android.util Slog v

List of usage examples for android.util Slog v

Introduction

In this page you can find the example usage for android.util Slog v.

Prototype

@UnsupportedAppUsage
    public static int v(String tag, String msg) 

Source Link

Usage

From source file:android.app.Activity.java

/**
 * Called when the activity is starting.  This is where most initialization
 * should go: calling {@link #setContentView(int)} to inflate the
 * activity's UI, using {@link #findViewById} to programmatically interact
 * with widgets in the UI, calling/*from  w w  w.j  av a 2s.  c  o m*/
 * {@link #managedQuery(android.net.Uri , String[], String, String[], String)} to retrieve
 * cursors for data being displayed, etc.
 * 
 * <p>You can call {@link #finish} from within this function, in
 * which case onDestroy() will be immediately called without any of the rest
 * of the activity lifecycle ({@link #onStart}, {@link #onResume},
 * {@link #onPause}, etc) executing.
 * 
 * <p><em>Derived classes must call through to the super class's
 * implementation of this method.  If they do not, an exception will be
 * thrown.</em></p>
 * 
 * @param savedInstanceState If the activity is being re-initialized after
 *     previously being shut down then this Bundle contains the data it most
 *     recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
 * 
 * @see #onStart
 * @see #onSaveInstanceState
 * @see #onRestoreInstanceState
 * @see #onPostCreate
 */
protected void onCreate(Bundle savedInstanceState) {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onCreate " + this + ": " + savedInstanceState);
    if (mLastNonConfigurationInstances != null) {
        mAllLoaderManagers = mLastNonConfigurationInstances.loaders;
    }
    if (mActivityInfo.parentActivityName != null) {
        if (mActionBar == null) {
            mEnableDefaultActionBarUp = true;
        } else {
            mActionBar.setDefaultDisplayHomeAsUpEnabled(true);
        }
    }

    if (isAvailable()) {
        /* if this device can use the platform */
        Log.w("MIGRATOR", "This is " + getLocalClassName());
        Intent intent = getIntent();
        Bundle tmpBundle = intent.getBundleExtra("MIGRATED");
        ArrayList<Bundle> stacked = intent.getParcelableArrayListExtra("MIGRATED STACK");
        if (tmpBundle != null) {
            /* true if this Activity was migrated */
            if (stacked != null) {
                /* true if this Activity called next Activity */
                Intent next = new Intent();
                Bundle nextBundle = stacked.get(0);
                next.setClassName(nextBundle.getString("MIGRATED PNAME"),
                        nextBundle.getString("MIGRATED CNAME"));
                next.putExtra("MIGRATED", nextBundle);
                stacked.remove(0);
                int code = tmpBundle.getInt("MIGRATED REQUEST CODE");
                Bundle option = nextBundle.getBundle("MIGRATED REQUEST OPTIONS");
                if (!stacked.isEmpty()) {
                    /* store for next Activity */
                    next.putParcelableArrayListExtra("MIGRATED STACK", stacked);
                }
                Log.w("MIGRATOR", "Start ForResult: code=" + code);
                mReceiverStackFlag = true;
                mStackedNextIntent = next;
                mStackedNextCode = code;
                mStackedNextOption = option;
            } else {
                /* for debug */
                Log.w("MIGRATOR", "stack is null");
            }
            savedInstanceState = null;
            mMigFlag = true;
            migratedState = tmpBundle;
            Intent tmpIntent = tmpBundle.getParcelable("MIGRATED_INTENT");
            if (tmpIntent != null) {
                tmpIntent.setAction(Intent.ACTION_MIGRATE);
                setIntent(tmpIntent);
            }

            /* File handling */
            ArrayList<String> tmpNames = tmpBundle.getStringArrayList("TARGET_FILE_NAME");
            if (tmpNames != null) {
                FileWorker fw = new FileWorker(tmpNames.toArray(new String[tmpNames.size()]),
                        FileWorker.WRITE_MODE);
                fw.start();
                tmpNames = null;
            }
            Log.w("MIGRATOR", "successed migaration: " + tmpBundle.toString());
            tmpBundle = null;
        } else {
            /* for debug */
            Log.w("MIGRATOR", "tmpBundle is null");
        }
    }

    if (savedInstanceState != null) {
        Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
        mFragments.restoreAllState(p,
                mLastNonConfigurationInstances != null ? mLastNonConfigurationInstances.fragments : null);
    }
    mFragments.dispatchCreate();
    getApplication().dispatchActivityCreated(this, savedInstanceState);
    mCalled = true;

}

From source file:android.app.Activity.java

/**
 * Called after {@link #onCreate} &mdash; or after {@link #onRestart} when  
 * the activity had been stopped, but is now again being displayed to the 
* user.  It will be followed by {@link #onResume}.
 *
 * <p><em>Derived classes must call through to the super class's
 * implementation of this method.  If they do not, an exception will be
 * thrown.</em></p>/*from   www  .  ja va2  s.c om*/
 * 
 * @see #onCreate
 * @see #onStop
 * @see #onResume
 */
protected void onStart() {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onStart " + this);
    mCalled = true;

    /* make the notification for migration */
    showMigrateNotification();

    if (!mLoadersStarted) {
        mLoadersStarted = true;
        if (mLoaderManager != null) {
            mLoaderManager.doStart();
        } else if (!mCheckedForLoaderManager) {
            mLoaderManager = getLoaderManager("(root)", mLoadersStarted, false);
        }
        mCheckedForLoaderManager = true;
    }

    getApplication().dispatchActivityStarted(this);

}

From source file:android.app.Activity.java

/**
 * Called after {@link #onRestoreInstanceState}, {@link #onRestart}, or
 * {@link #onPause}, for your activity to start interacting with the user.
 * This is a good place to begin animations, open exclusive-access devices
 * (such as the camera), etc./*from  w w w.  j a  v  a2  s.c om*/
 *
 * <p>Keep in mind that onResume is not the best indicator that your activity
 * is visible to the user; a system window such as the keyguard may be in
 * front.  Use {@link #onWindowFocusChanged} to know for certain that your
 * activity is visible to the user (for example, to resume a game).
 *
 * <p><em>Derived classes must call through to the super class's
 * implementation of this method.  If they do not, an exception will be
 * thrown.</em></p>
 * 
 * @see #onRestoreInstanceState
 * @see #onRestart
 * @see #onPostResume
 * @see #onPause
 */
protected void onResume() {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onResume " + this);
    getApplication().dispatchActivityResumed(this);
    mCalled = true;
    if (mReceiverStackFlag) {
        /* call next Activity if it exits */
        startActivityForResult(mStackedNextIntent, mStackedNextCode, mStackedNextOption);
        mStackedNextIntent = null;
        mStackedNextCode = -1;
        mStackedNextOption = null;
        mReceiverStackFlag = false;
    }
}

From source file:android.app.Activity.java

/**
 * The hook for {@link ActivityThread} to save the state of this activity.
 *
 * Calls {@link #onSaveInstanceState(android.os.Bundle)}
 * and {@link #saveManagedDialogs(android.os.Bundle)}.
 *
 * @param outState The bundle to save the state to.
 *///from w  ww  . j a  va 2 s. c o m
final void performSaveInstanceState(Bundle outState) {
    onSaveInstanceState(outState);
    saveManagedDialogs(outState);
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onSaveInstanceState " + this + ": " + outState);
}

From source file:android.app.Activity.java

/**
 * Called as part of the activity lifecycle when an activity is going into
 * the background, but has not (yet) been killed.  The counterpart to
 * {@link #onResume}.//from w w w.  j  a va  2 s  .  com
 *
 * <p>When activity B is launched in front of activity A, this callback will
 * be invoked on A.  B will not be created until A's {@link #onPause} returns,
 * so be sure to not do anything lengthy here.
 *
 * <p>This callback is mostly used for saving any persistent state the
 * activity is editing, to present a "edit in place" model to the user and
 * making sure nothing is lost if there are not enough resources to start
 * the new activity without first killing this one.  This is also a good
 * place to do things like stop animations and other things that consume a
 * noticeable amount of CPU in order to make the switch to the next activity
 * as fast as possible, or to close resources that are exclusive access
 * such as the camera.
 * 
 * <p>In situations where the system needs more memory it may kill paused
 * processes to reclaim resources.  Because of this, you should be sure
 * that all of your state is saved by the time you return from
 * this function.  In general {@link #onSaveInstanceState} is used to save
 * per-instance state in the activity and this method is used to store
 * global persistent data (in content providers, files, etc.)
 * 
 * <p>After receiving this call you will usually receive a following call
 * to {@link #onStop} (after the next activity has been resumed and
 * displayed), however in some cases there will be a direct call back to
 * {@link #onResume} without going through the stopped state.
 * 
 * <p><em>Derived classes must call through to the super class's
 * implementation of this method.  If they do not, an exception will be
 * thrown.</em></p>
 * 
 * @see #onResume
 * @see #onSaveInstanceState
 * @see #onStop
 */
protected void onPause() {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onPause " + this);
    getApplication().dispatchActivityPaused(this);
    mCalled = true;

    /* remove the migration notification */
    NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(Process.myUid());

    /* set Bundle for migration */
    if (isAvailable()) {
        Bundle tmpBundle = new Bundle();
        performSaveInstanceState(tmpBundle);
        systemMigrate(tmpBundle);
    }
}

From source file:android.app.Activity.java

/**
 * Called when you are no longer visible to the user.  You will next
 * receive either {@link #onRestart}, {@link #onDestroy}, or nothing,
 * depending on later user activity.// w  ww  .  j  av a 2s .c  o m
 * 
 * <p>Note that this method may never be called, in low memory situations
 * where the system does not have enough memory to keep your activity's
 * process running after its {@link #onPause} method is called.
 * 
 * <p><em>Derived classes must call through to the super class's
 * implementation of this method.  If they do not, an exception will be
 * thrown.</em></p>
 * 
 * @see #onRestart
 * @see #onResume
 * @see #onSaveInstanceState
 * @see #onDestroy
 */
protected void onStop() {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onStop " + this);
    if (mActionBar != null)
        mActionBar.setShowHideAnimationEnabled(false);
    getApplication().dispatchActivityStopped(this);
    mTranslucentCallback = null;
    mCalled = true;
}

From source file:android.app.Activity.java

/**
 * Perform any final cleanup before an activity is destroyed.  This can
 * happen either because the activity is finishing (someone called
 * {@link #finish} on it, or because the system is temporarily destroying
 * this instance of the activity to save space.  You can distinguish
 * between these two scenarios with the {@link #isFinishing} method.
 * /*  w w w .  ja va 2  s . c o  m*/
 * <p><em>Note: do not count on this method being called as a place for
 * saving data! For example, if an activity is editing data in a content
 * provider, those edits should be committed in either {@link #onPause} or
 * {@link #onSaveInstanceState}, not here.</em> This method is usually implemented to
 * free resources like threads that are associated with an activity, so
 * that a destroyed activity does not leave such things around while the
 * rest of its application is still running.  There are situations where
 * the system will simply kill the activity's hosting process without
 * calling this method (or any others) in it, so it should not be used to
 * do things that are intended to remain around after the process goes
 * away.
 * 
 * <p><em>Derived classes must call through to the super class's
 * implementation of this method.  If they do not, an exception will be
 * thrown.</em></p>
 * 
 * @see #onPause
 * @see #onStop
 * @see #finish
 * @see #isFinishing
 */
protected void onDestroy() {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onDestroy " + this);
    mCalled = true;

    // dismiss any dialogs we are managing.
    if (mManagedDialogs != null) {
        final int numDialogs = mManagedDialogs.size();
        for (int i = 0; i < numDialogs; i++) {
            final ManagedDialog md = mManagedDialogs.valueAt(i);
            if (md.mDialog.isShowing()) {
                md.mDialog.dismiss();
            }
        }
        mManagedDialogs = null;
    }

    // close any cursors we are managing.
    synchronized (mManagedCursors) {
        int numCursors = mManagedCursors.size();
        for (int i = 0; i < numCursors; i++) {
            ManagedCursor c = mManagedCursors.get(i);
            if (c != null) {
                c.mCursor.close();
            }
        }
        mManagedCursors.clear();
    }

    // Close any open search dialog
    if (mSearchManager != null) {
        mSearchManager.stopSearch();
    }

    getApplication().dispatchActivityDestroyed(this);
}

From source file:android.app.Activity.java

/**
 * Called by the system when the device configuration changes while your
 * activity is running.  Note that this will <em>only</em> be called if
 * you have selected configurations you would like to handle with the
 * {@link android.R.attr#configChanges} attribute in your manifest.  If
 * any configuration change occurs that is not selected to be reported
 * by that attribute, then instead of reporting it the system will stop
 * and restart the activity (to have it launched with the new
 * configuration)./*w  w w .ja v  a2  s  .com*/
 * 
 * <p>At the time that this function has been called, your Resources
 * object will have been updated to return resource values matching the
 * new configuration.
 * 
 * @param newConfig The new device configuration.
 */
public void onConfigurationChanged(Configuration newConfig) {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onConfigurationChanged " + this + ": " + newConfig);
    mCalled = true;

    mFragments.dispatchConfigurationChanged(newConfig);

    if (mWindow != null) {
        // Pass the configuration changed event to the window
        mWindow.onConfigurationChanged(newConfig);
    }

    if (mActionBar != null) {
        // Do this last; the action bar will need to access
        // view changes from above.
        mActionBar.onConfigurationChanged(newConfig);
    }
}

From source file:android.app.Activity.java

public void onLowMemory() {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onLowMemory " + this);
    mCalled = true;//from  w w w  .  j av  a2  s.c  o  m
    mFragments.dispatchLowMemory();
}

From source file:android.app.Activity.java

public void onTrimMemory(int level) {
    if (DEBUG_LIFECYCLE)
        Slog.v(TAG, "onTrimMemory " + this + ": " + level);
    mCalled = true;//from  w w w  . j a  va 2s. co  m
    mFragments.dispatchTrimMemory(level);
}