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:com.github.rutvijkumar.twittfuse.Util.java

private static void showUsersListActivity(String userScreenName, boolean isFollowersList, Activity activity) {
    Intent intent = new Intent(activity, UserListActivity.class);
    intent.putExtra("isFollowersList", isFollowersList);
    intent.putExtra("userScreenName", userScreenName);
    activity.startActivity(intent);
}

From source file:Main.java

/**
 * Show dialog and give 2 options: go to settings or leave the app
 *
 * @param activity the activity//www. j  a  v  a2 s.  c  om
 */
private static void showDialog(final Activity activity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    builder.setTitle("Bluetooth is turned off");
    builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON");
    builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
            activity.startActivity(setnfc);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            activity.finish();
        }
    });
    builder.show();
}

From source file:com.android.contacts.common.activity.RequestPermissionsActivityBase.java

/**
 * If any permissions the Contacts app needs are missing, open an Activity
 * to prompt the user for these permissions. Moreover, finish the current activity.
 *
 * This is designed to be called inside {@link android.app.Activity#onCreate}
 *//* w  ww.  java 2s  . c  o  m*/
protected static boolean startPermissionActivity(Activity activity, String[] requiredPermissions,
        Class<?> newActivityClass) {
    if (!hasPermissions(activity, requiredPermissions)) {
        final Intent intent = new Intent(activity, newActivityClass);
        activity.getIntent().putExtra(STARTED_PERMISSIONS_ACTIVITY, true);
        intent.putExtra(PREVIOUS_ACTIVITY_INTENT, activity.getIntent());
        activity.startActivity(intent);
        activity.finish();
        return true;
    }

    // Account type initialization must be delayed until the Contacts permission group
    // has been granted (since GET_ACCOUNTS) falls under that groups.  Previously it
    // was initialized in ContactApplication which would cause problems as
    // AccountManager.getAccounts would return an empty array. See b/22690336
    AccountTypeManager.getInstance(activity);

    return false;
}

From source file:com.shafiq.mytwittle.view.ImageViewActivity.java

public static void createAndStartActivity(Activity currentActivity, String mediaUrl, String sourceUrl,
        String authorScreenName) {
    Intent intent = new Intent(currentActivity, ImageViewActivity.class);
    intent.putExtra(KEY_MEDIA_URL, mediaUrl);
    intent.putExtra(KEY_SOURCE_URL, sourceUrl);
    intent.putExtra(KEY_AUTHOR_SCREEN_NAME, authorScreenName);
    currentActivity.startActivity(intent);
}

From source file:Main.java

public static void showGPSSettings(final Activity activity) {
    // check for internet connection
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(activity);
    alertDialog.setTitle("GPS adapter disabled");
    alertDialog.setMessage("GPS is not enabled. Please enable GPS");
    // Setting Positive "Yes" Button
    alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            activity.startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
        }//w w  w  .  j  a  va  2  s.co  m
    });
    // Setting Negative "NO" Button
    alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    // Showing Alert Message
    alertDialog.show();
}

From source file:codepath.watsiapp.utils.Util.java

public static void startShareIntent(Activity activity, ShareableItem patient) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl());
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment");
    activity.startActivity(Intent.createChooser(shareIntent, "Share Story"));
}

From source file:com.becapps.easydownloader.utils.Utils.java

public static void reload(Activity activity) {
    Intent intent = activity.getIntent();
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    activity.finish();//from   ww w .  j av  a2  s.c om
    activity.overridePendingTransition(0, 0);
    activity.startActivity(intent);
    activity.overridePendingTransition(0, 0);
}

From source file:com.github.baoti.pioneer.ui.Navigator.java

/**
 * ?,?Splash?/* ww w . j a  va2  s .  c  o m*/
 * @param activity
 */
public static void upToMain(Activity activity) {
    Intent intent = new Intent(activity, MainActivity.class);
    //        NavUtils.navigateUpTo(activity, intent);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    if (activity instanceof MainActivity) {
        ((MainActivity) activity).close();
    }
    activity.startActivity(intent);
    activity.overridePendingTransition(0, 0);
    if (!(activity instanceof MainActivity)) {
        ActivityCompat.finishAffinity(activity);
        activity.overridePendingTransition(0, android.R.anim.fade_out);
    }
}

From source file:com.phunkosis.gifstitch.helpers.ShareHelper.java

public static void startShareLinkIntent(Activity activity, String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_TEXT, activity.getResources().getString(R.string.share_link_body) + " " + url);
    intent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.share_link_subject));
    intent.setType("text/plain");
    activity.startActivity(Intent.createChooser(intent, "Share "));
}

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  w w  w .  j  a  v  a 2s  .c  o 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();

}