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:Main.java

/**
 * Create a precondition activity intent.
 * //from ww w  .  j  av a  2  s .co m
 * @param activity
 *            the original activity
 * @param preconditionActivityClazz
 *            the precondition activity's class
 * @return an intent which will launch the precondition activity.
 */
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;
}

From source file:Main.java

static String getCallingPackageName(Activity activity) {
    // getCallingPackage() was unstable until android-18, use this
    String packageName = activity.getCallingActivity().getPackageName();
    if (TextUtils.isEmpty(packageName)) {
        packageName = activity.getIntent().getPackage();
    }//from ww  w .  j a v  a 2s . com
    if (TextUtils.isEmpty(packageName)) {
        Log.e(activity.getPackageName(),
                "Received blank Panic.ACTION_DISCONNECT Intent, it must be sent using startActivityForResult()!");
    }
    return packageName;
}

From source file:Main.java

public static void restartActivity(Activity activity) {

    if (activity == null)
        return;//  w w  w.j a  va 2 s  .com

    if (Build.VERSION.SDK_INT >= 11) {
        activity.recreate();
    } else {
        Intent intent;
        intent = activity.getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION
                | Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.finish();
        activity.overridePendingTransition(0, 0);
        activity.startActivity(intent);
        activity.overridePendingTransition(0, 0);
    }

}

From source file:com.microsoft.azure.engagement.unity.EngagementWrapper.java

public static void setAndroidActivity(Activity _androidActivity) {

    androidActivity = _androidActivity;//from  w  w w .  j  a v a2  s . c o  m
    Uri data = _androidActivity.getIntent().getData();
    if (data != null) {
        String lastUrl = data.toString();
        handleOpenURL(lastUrl);
    }
}

From source file:de.dreier.mytargets.utils.transitions.FabTransform.java

/**
 * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its
 * shared element enter/return transition.
 *//*www  .  j a va2 s.  co m*/
static boolean setup(@NonNull Activity activity, @Nullable View target) {
    final Intent intent = activity.getIntent();
    if (!intent.hasExtra(EXTRA_FAB_COLOR_RES) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) {
        return false;
    }

    final int colorRes = intent.getIntExtra(EXTRA_FAB_COLOR_RES, R.color.colorAccent);
    final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1);
    final int color = ContextCompat.getColor(activity, colorRes);
    final FabTransform sharedEnter = new FabTransform(color, icon);
    if (target != null) {
        sharedEnter.addTarget(target);
    }
    activity.getWindow().setSharedElementEnterTransition(sharedEnter);
    return true;
}

From source file:ameircom.keymedia.Activity.transition.FabTransform.java

/**
 * Create a {@link FabTransform} from the supplied {@code activity} extras and set as its
 * shared element enter/return transition.
 *///  w ww.  ja v  a 2  s.c om
public static boolean setup(@NonNull Activity activity, @Nullable View target) {
    final Intent intent = activity.getIntent();
    if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) {
        return false;
    }

    final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT);
    final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1);
    final FabTransform sharedEnter = new FabTransform(color, icon);
    if (target != null) {
        sharedEnter.addTarget(target);
    }
    activity.getWindow().setSharedElementEnterTransition(sharedEnter);
    return true;
}

From source file:org.solovyev.android.calculator.App.java

public static void restartActivity(@Nonnull Activity activity) {
    final Intent intent = activity.getIntent();
    activity.finish();//w  w w.j  a  v a 2s .c  o  m
    activity.startActivity(intent);
}

From source file:ccv.checkhelzio.nuevaagendacucsh.transitions.FabTransition.java

/**
 * Create a {@link FabTransition} from the supplied {@code activity} extras and set as its
 * shared element enter/return transition.
 */// w w w. j a va2 s .  c o m
public static boolean setup(@NonNull Activity activity, @Nullable View target) {
    final Intent intent = activity.getIntent();
    if (!intent.hasExtra(EXTRA_FAB_COLOR) || !intent.hasExtra(EXTRA_FAB_ICON_RES_ID)) {
        return false;
    }

    final int color = intent.getIntExtra(EXTRA_FAB_COLOR, Color.TRANSPARENT);
    final int icon = intent.getIntExtra(EXTRA_FAB_ICON_RES_ID, -1);
    final FabTransition sharedEnter = new FabTransition(color, icon);
    if (target != null) {
        sharedEnter.addTarget(target);
    }
    activity.getWindow().setSharedElementEnterTransition(sharedEnter);
    return true;
}

From source file:net.wequick.small.Small.java

public static Uri getUri(Activity context) {
    android.os.Bundle extras = context.getIntent().getExtras();
    if (extras == null) {
        return null;
    }/*w  w  w  .  j  ava2s  .c o  m*/
    String query = extras.getString(KEY_QUERY);
    if (query == null) {
        return null;
    }
    return Uri.parse(query);
}

From source file:tw.com.ksmt.cloud.libs.Utils.java

public static void restartActivity(Context context) {
    Activity activity = (Activity) context;
    Intent intent = activity.getIntent();
    activity.finish();// w  w  w  .j  a v  a  2  s. co m
    activity.startActivity(intent);
}