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 doCall(Activity aty, String mobile) throws Exception {
    if (null != aty && null != mobile) {
        Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + mobile));
        phoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        aty.startActivity(phoneIntent);
    }//  w  w  w. j  a  va 2 s .c  om
}

From source file:com.agna.setmaster.ui.screen.editprofile.EditProfileActivity.java

public static void start(Activity activity, Profile profile) {
    Intent i = new Intent(activity, EditProfileActivity.class);
    i.putExtra(EXTRA_PROFILE, profile);/*from   w ww .ja v a 2s . co  m*/
    activity.startActivity(i);
}

From source file:cn.tofly.mis.waterusermanager.common.tools.ActivityUtils.java

/**
 * ?Activity/*from w  w w .j  a  v  a 2s  .c o  m*/
 *
 * @param context
 * @param clazz
 * @param bundle
 */
public static void startActivity(Activity context, Class clazz, Bundle bundle) {
    if (context != null) {
        try {
            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 recreate(@NonNull Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        activity.recreate();/*from   www. j a  va 2 s . 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 boolean gotoGoogleMarket(Activity activity, String pck) {
    try {/*w  w  w .  j a  v  a  2 s.  c  om*/
        Intent intent = new Intent();
        intent.setPackage("com.android.vending");
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=" + pck));
        activity.startActivity(intent);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static void share(Activity activity, String subject, String text, @StringRes int titleResId) {
    Intent intent = ShareCompat.IntentBuilder.from(activity).setType("text/plain").setSubject(subject.trim())
            .setText(text.trim()).setChooserTitle(titleResId).createChooserIntent();
    activity.startActivity(intent);
}

From source file:Main.java

public static void startURLActivity(Activity context, String strURL) {

    if (strURL == null)
        return;//from   w  w w  .j  a va 2  s  .c  om

    if (URLUtil.isValidUrl(strURL) == false)
        return;

    Uri url = Uri.parse(strURL);

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(url);
    context.startActivity(i);
}

From source file:Main.java

public static void install(Activity activity, File apk_file) {
    Intent intent = new Intent();
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setAction(android.content.Intent.ACTION_VIEW);
    intent.setDataAndType(Uri.fromFile(apk_file), "application/vnd.android.package-archive");
    activity.startActivity(intent);
}

From source file:Main.java

public static void restartApp(Activity activity) {
    if (activity == null) {
        return;/* w  w  w .j  a  va 2s .c  om*/
    }
    Intent i = activity.getBaseContext().getPackageManager()
            .getLaunchIntentForPackage(activity.getBaseContext().getPackageName());
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    activity.startActivity(i);
    activity.finish();
}

From source file:butter.droid.tv.activities.TVStreamLoadingActivity.java

public static Intent startActivity(Activity activity, StreamInfo info, Show show) {
    Intent i = new Intent(activity, TVStreamLoadingActivity.class);
    i.putExtra(EXTRA_STREAM_INFO, info);
    i.putExtra(EXTRA_SHOW_INFO, show);// w  w w  .  j a v a 2  s  .co  m
    activity.startActivity(i);
    return i;
}