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 mail(Activity activity, String subject, String text, String mail) {

    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:" + mail));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);

    activity.startActivity(intent);

}

From source file:Main.java

/**
 * Enables back navigation for activities that are launched from the NavBar. See {@code
 * AndroidManifest.xml} to find out the parent activity names for each activity.
 *
 * @param intent/*w  w  w.java  2 s . c o m*/
 */
public static void createBackStack(Activity activity, Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(activity);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        activity.startActivity(intent);
        activity.finish();
    }
}

From source file:Main.java

public static void newClearTask(Activity activity, Class<?> homeActivityClass) {
    activity.finish();// w  w w . j  ava 2s .  c  o m
    Intent intent = new Intent(activity, homeActivityClass);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
            | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivity(intent);
}

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

public static void starShowMedicalPartnerIntent(Activity activity, String url) {
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    activity.startActivity(browserIntent);
}

From source file:at.ac.tuwien.caa.docscan.ActivityUtils.java

/**
 * Enables back navigation for activities that are launched from the NavBar. See {@code
 * AndroidManifest.xml} to find out the parent activity names for each activity.
 *
 * @param intent/*from   w ww. j a va2  s .co m*/
 */
public static void createBackStack(Activity activity, Intent intent) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        TaskStackBuilder builder = TaskStackBuilder.create(activity);
        builder.addNextIntentWithParentStack(intent);
        builder.startActivities();
    } else {
        activity.startActivity(intent);
        activity.finish();
    }

    //        Use our own animation - instead of the default scaling animation:
    activity.overridePendingTransition(R.anim.translate_in, R.anim.translate_out);
}

From source file:Main.java

public static void openLink(Activity activity, String url) {
    if (url == null)
        return;//  w  w  w. j a  v  a  2 s  .c om
    if (!url.startsWith("http://") && !url.startsWith("https://"))
        url = "http://" + url;
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse(url));
    intent = Intent.createChooser(intent, null);
    activity.startActivity(intent);
}

From source file:Main.java

public static void showNfcSettingsDialog(final Activity app) {
    new AlertDialog.Builder(app).setTitle("NFC is disabled").setMessage("You must enable NFC to use this app.")
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    app.startActivity(new Intent(android.provider.Settings.ACTION_NFC_SETTINGS));
                }/*from w w w.jav  a 2s. c  o  m*/
            }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    app.finish();
                }
            }).setIcon(android.R.drawable.ic_dialog_alert).show();
}

From source file:com.google.samples.apps.iosched.session.SessionDetailActivity.java

public static void startSessionDetailActivity(final Activity activity, final String sessionId) {
    Uri data = ScheduleContract.Sessions.buildSessionUri(sessionId);
    Intent sessionDetailIntent = new Intent(activity, SessionDetailActivity.class);
    sessionDetailIntent.setData(data);//from   w w w  .j a va 2 s .  c o m
    activity.startActivity(sessionDetailIntent);
}

From source file:Main.java

public static void installApkFromLocalPath(Activity activity, String apkname) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(//from  w  w w .ja  va 2 s  .  c  o  m
            Uri.parse("file://" + Environment.getExternalStorageDirectory() + "/ewgvip/" + apkname),
            "application/vnd.android.package-archive");
    activity.startActivity(intent);
}

From source file:Main.java

public static void sendSchemeForResultAddMediaStack(Activity context, String mediaActivityUrl, String url,
        int requestCode, Bundle bundle) {
    Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(mediaActivityUrl));
    intent.addFlags(67108864);/*from w  w w .  jav  a2s.com*/
    context.startActivity(intent);
    intent = new Intent("android.intent.action.VIEW", Uri.parse(url));
    if (bundle != null) {
        intent.putExtras(bundle);
    }

    context.startActivityForResult(intent, requestCode);
}