Example usage for android.app Activity startActivity

List of usage examples for android.app Activity startActivity

Introduction

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

Prototype

@Override
public void startActivity(Intent intent) 

Source Link

Document

Same as #startActivity(Intent,Bundle) with no options specified.

Usage

From source file:Main.java

public static void restart(final @NonNull Activity activity) {
    if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
        activity.recreate();/*from  ww  w  .j  ava 2  s  .  c o  m*/
    } else {
        final Intent intent = activity.getIntent();
        activity.finish();
        activity.startActivity(intent);
    }
}

From source file:Main.java

public static void startIntentWithoutHistory(Activity activity, Class intentClass) {
    Intent intent = new Intent(activity, intentClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);
}

From source file:Main.java

public static void startActivity(Activity context, Class clazz, Bundle bundle) {
    if (context != null) {
        try {/*w  w w .j  a  va 2  s  .  c om*/
            Intent intent = new Intent(context, clazz);
            intent.putExtra("bundle", bundle);
            context.startActivity(intent);

        } catch (ActivityNotFoundException e) {
            e.printStackTrace();

        }

    }
}

From source file:Main.java

public static void startActivityClearTask(Activity activity, Class<? extends Activity> clazz) {
    Intent intent = new Intent(activity, clazz);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);
    activity.overridePendingTransition(0, 0);
}

From source file:Main.java

/**
 * Method to open entry of app "OI Notepad" in Google's appstore.
 * Before the intent is actually is dispatched method 
 * {@link de.chbosync.android.syncmlclient.source.pim.note.OINoteCheckInstalled#isIntentSupported(Intent, Context)}
 * is invoked to find out if the current device can handle this intent 
 * (if we would dispatch this intent and the device is not capable of handling it, 
 * then the app would crash). /*from w  w  w . ja va 2s . co m*/
 * 
 * @param activity Reference to callling activity, needed to dispatch implicit intent.
 * 
 * @return <tt>True</tt> if no error occured, <tt>false</tt> if an error occured.
 */
public static boolean openEntryForOINotepadInAppstore(Activity activity) {

    Intent intent = createIntentForOINotepadAppstoreEntry();

    if (isIntentToOpenAppStoreClientSupported(activity)) {

        activity.startActivity(intent);
        return true;

    } else {

        return false;
    }
}

From source file:com.github.dfa.diaspora_android.util.Helpers.java

public static void animateToActivity(Activity from, Class to, boolean finishFromActivity) {
    Intent intent = new Intent(from, to);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    from.startActivity(intent);
    from.overridePendingTransition(R.anim.fadein, R.anim.fadeout);
    if (finishFromActivity) {
        from.finish();/*from w  w  w .  j a v  a  2s.c  om*/
    }
}

From source file:Main.java

/**
 * Finish the given activity and start a home activity class.
 * <p/>//from  w  w w. j av  a  2  s  .  c o m
 * This mirror the behavior of the home action bar button that clears the
 * current activity and starts or brings another activity to the top.
 *
 * @param activity
 * @param homeActivityClass
 */
public static void goHome(Activity activity, Class<?> homeActivityClass) {
    activity.finish();
    Intent intent = new Intent(activity, homeActivityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    activity.startActivity(intent);
}

From source file:Main.java

public static void searchMarket(Activity caller, String paramtype, String value) {
    Uri uri = Uri.parse("market://search?q=" + paramtype + ":" + value);
    Intent intent = new Intent();
    intent.setData(uri);//  w  w  w .j  a v  a2  s.  c o m
    intent.setAction(Intent.ACTION_VIEW);
    caller.startActivity(intent);
}

From source file:Main.java

public static void goHome(Activity currentActivity, Class<?> homeActivityClass) {
    Intent parentActivityIntent = new Intent(currentActivity, homeActivityClass);
    parentActivityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
    currentActivity.startActivity(parentActivityIntent);
    currentActivity.finish();/*from w ww  .ja  va 2  s  .  com*/
}

From source file:Main.java

public static void startShareIntentActivity(Activity activity, String text) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SEND);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, text);
    activity.startActivity(intent);
}