Example usage for android.app Activity getIntent

List of usage examples for android.app Activity getIntent

Introduction

In this page you can find the example usage for android.app Activity getIntent.

Prototype

public Intent getIntent() 

Source Link

Document

Return the intent that started this activity.

Usage

From source file:net.xkor.genaroid.Genaroid.java

public static void readParams(@NonNull Activity activity) {
    if (activity.getIntent() != null) {
        readParams(activity, activity.getIntent().getExtras());
    }//w  w  w.ja va  2  s . c  om
}

From source file:Main.java

/**
 * Start the original activity, and finish the precondition activity.
 * /*from  w  w w.j  av  a 2 s . c o  m*/
 * @param preconditionActivity
 */
public static void startOriginalActivityAndFinish(Activity preconditionActivity) {
    preconditionActivity.finish();
    preconditionActivity
            .startActivity((Intent) preconditionActivity.getIntent().getParcelableExtra(EXTRA_WRAPPED_INTENT));
}

From source file:Main.java

/**
 * Restarts activity, from http://stackoverflow.com/questions/1397361/how-do-i-restart-an-android-activity
 * @param activity the activity to restart
 *///from  ww w .jav a  2 s  .  co m
@TargetApi(11)
public static void restartActivity(Activity activity) {
    if (Build.VERSION.SDK_INT >= 11) {
        activity.recreate();
    } else {
        Intent intent = activity.getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        activity.finish();
        activity.overridePendingTransition(0, 0);

        activity.startActivity(intent);
        activity.overridePendingTransition(0, 0);
    }
}

From source file:Main.java

public static void restart(final @NonNull Activity activity) {
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        activity.recreate();//from www .  j  a v a  2s  .com
    } else {
        final Intent intent = activity.getIntent();
        activity.finish();
        activity.startActivity(intent);
    }
}

From source file:Main.java

public static void recreate(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();//from ww w.  j  a  v a  2s.  co  m
    } else {
        Intent intent = activity.getIntent();
        intent.setClass(activity, activity.getClass());
        activity.startActivity(intent);
        activity.finish();
        activity.overridePendingTransition(0, 0);
    }
}

From source file:Main.java

public static void restartClearActivity(Activity activity) {
    if (activity == null)
        return;/*from  www  . ja va 2 s  . co m*/
    Context ctx = activity.getApplicationContext();
    Intent intent;
    intent = activity.getIntent();
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    activity.finish();
    activity.overridePendingTransition(0, 0);

    ctx.startActivity(intent);
    activity.overridePendingTransition(0, 0);

}

From source file:Main.java

/**
 * Helper method to recreate the Activity. This method should be called after a Locale change.
 * @param activity the Activity that will be recreated
 * @param animate a flag indicating if the recreation will be animated or not
 *//*from ww  w.  ja v a 2s . co  m*/
public static void recreate(Activity activity, boolean animate) {
    Intent restartIntent = new Intent(activity, activity.getClass());

    Bundle extras = activity.getIntent().getExtras();
    if (extras != null) {
        restartIntent.putExtras(extras);
    }

    if (animate) {
        ActivityCompat.startActivity(activity, restartIntent, ActivityOptionsCompat
                .makeCustomAnimation(activity, android.R.anim.fade_in, android.R.anim.fade_out).toBundle());
    } else {
        activity.startActivity(restartIntent);
        activity.overridePendingTransition(0, 0);
    }

    activity.finish();

}

From source file:Main.java

/**
 * Restart the Activity/*from  ww  w .j a va 2 s  . co m*/
 *
 * @param activity
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void restartActivity(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();
    } else {
        Intent intent = activity.getIntent();
        activity.overridePendingTransition(0, 0);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        activity.finish();

        activity.overridePendingTransition(0, 0);
        activity.startActivity(intent);
    }
}

From source file:Main.java

public static void restartClearActivityOutside(Activity activity) {
    if (activity == null)
        return;//from  www  . j  a  v  a  2  s  . com
    Context ctx = activity.getApplicationContext();
    Intent intent;
    intent = activity.getIntent();
    intent.addFlags(
            Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    activity.finish();
    activity.overridePendingTransition(0, 0);

    ctx.startActivity(intent);
    activity.overridePendingTransition(0, 0);

}

From source file:Main.java

/**
 * Create a precondition activity intent.
 * @param activity the original activity
 * @param preconditionActivityClazz the precondition activity's class
 * @return an intent which will launch the precondition activity.
 *///from  www .  ja v a  2s  . co  m
public static Intent createPreconditionIntent(Activity activity, Class preconditionActivityClazz) {
    Intent newIntent = new Intent();
    newIntent.setClass(activity, preconditionActivityClazz);
    newIntent.putExtra(EXTRA_WRAPPED_INTENT, activity.getIntent());
    return newIntent;
}