Example usage for android.content Context startActivity

List of usage examples for android.content Context startActivity

Introduction

In this page you can find the example usage for android.content Context startActivity.

Prototype

public abstract void startActivity(@RequiresPermission Intent intent);

Source Link

Document

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

Usage

From source file:Main.java

public static void startApplication(Context context, String packageName) {
    try {/*from  w  w  w . j av  a  2  s  .c om*/
        Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void UnInstallApk(Context context, String pkName) {
    Uri packageURI = Uri.parse(pkName);/*from w  w w . ja  va 2s.c o  m*/
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    context.startActivity(uninstallIntent);
}

From source file:Main.java

public static void callPhone(Context context, String number) {
    String tel = "tel:" + number;
    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(tel));
    context.startActivity(intent);
}

From source file:Main.java

public static void ActivityChange(Context context, Class<?> toClass) {
    ((Activity) context).finish();/* ww w. j a v  a  2  s  . c o m*/
    Intent intent = new Intent();
    intent.setClass(context, toClass);
    context.startActivity(intent);
}

From source file:Main.java

public static void makeCall(String phoneNumber, Context context) {
    String number = String.format("tel:%s", phoneNumber);
    Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(number));
    context.startActivity(callIntent);
}

From source file:Main.java

public static void gotoCall(Context context, String phoneNumber) {
    try {/*from  www . ja va 2s .c  om*/
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel://" + phoneNumber));
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Launches the URI specified./*from  w  w  w  . java2s .  co  m*/
 *
 * @param context
 * @param uri The URI to launch.
 * @return <b>true</b> if the URI is valid and there are available apps to handle it, <b>false</b> otherwise
 */
public static boolean launchURI(Context context, String uri) {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    try {
        context.startActivity(intent);
        return true;
    } catch (ActivityNotFoundException e) {
        return false;
    }
}

From source file:Main.java

public static void jumpToNewTopActivity(Context context, Class<? extends Activity> targetClass) {
    Intent datatIntent = new Intent(context, targetClass);
    datatIntent.setFlags(335544320);//from  www.j a v a  2s. c  o  m
    context.startActivity(datatIntent);
}

From source file:Main.java

public static void phoneCall(Context context, String phoneNumber) {
    Uri phoneCall = Uri.parse("tel:" + phoneNumber);
    Intent caller = new Intent(Intent.ACTION_DIAL, phoneCall);
    context.startActivity(caller);
}

From source file:Main.java

public static void startActivity(@NonNull Context context, @NonNull Intent intent,
        @Nullable CharSequence title) {
    if (hasResolution(context, intent)) {
        context.startActivity(intent);
    } else {/*from   w  w w.j  a v  a 2 s.  c om*/
        context.startActivity(Intent.createChooser(intent, title));
    }
}