List of usage examples for android.content Context startActivity
public abstract void startActivity(@RequiresPermission Intent intent);
From source file:Main.java
public static void uninstallApk(Context context, String packageName) { Intent intent = new Intent("android.intent.action.DELETE"); Uri packageURI = Uri.parse("package:" + packageName); intent.setData(packageURI);/*from w w w. j a v a 2 s . c o m*/ context.startActivity(intent); }
From source file:Main.java
public static void openDefaultBrowser(Context context, String url) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); Uri content_url = Uri.parse(url);/*from w ww.ja v a2s . c o m*/ intent.setData(content_url); context.startActivity(intent); }
From source file:Main.java
public static void jumpToSystemInstallApkActivity(Context context, String apkPath) { Intent intent = new Intent("android.intent.action.VIEW"); intent.setDataAndType(Uri.fromFile(new File(apkPath)), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
/** * Start an intent. If it is possible for this app to handle the intent, force this app's * activity to handle the intent. Sometimes it is impossible to know whether this app * can handle an intent while coding since the code is used inside both Dialer and Contacts. * This method is particularly useful in such circumstances. * * On a Nexus 5 with a small number of apps, this method consistently added 3-16ms of delay * in order to talk to the package manager. *//* w ww. ja v a 2 s . c om*/ public static void startActivityInAppIfPossible(Context context, Intent intent) { final Intent appIntent = getIntentInAppIfExists(context, intent); if (appIntent != null) { context.startActivity(appIntent); } else { context.startActivity(intent); } }
From source file:Main.java
public static void installApk(Context context, File filename) { Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.fromFile(filename)); context.startActivity(intent); }
From source file:Main.java
public static void sendSMS(Context context, String tel, String message) { Uri uri = Uri.parse("smsto:" + tel); Intent sendIntent = new Intent(Intent.ACTION_VIEW, uri); sendIntent.putExtra("sms_body", message); context.startActivity(sendIntent); }
From source file:Main.java
public static void goPage(Context context, Class<?> gopage, String extraName, Parcelable extraValue) { Intent intent = new Intent(context, gopage); intent.putExtra(extraName, extraValue); context.startActivity(intent); }
From source file:Main.java
public static void uninstall(Context context, String pkg) { if (pkg == null) { return;//from www.j a v a2s . c om } Uri uri = Uri.fromParts("package", pkg, null); Intent intent = new Intent(Intent.ACTION_DELETE, uri); context.startActivity(intent); }
From source file:Main.java
/** * Launches to the specific app in the Android Marketplace. * * @param context Application or Activity context * @param action Desired action// www .jav a 2 s . c o m */ public static void launchToMarketplace(final Context context, final String action) { final Uri intentUri = Uri.parse("market://search?q=pname:" + action); final Intent intent = new Intent(Intent.ACTION_VIEW, intentUri); context.startActivity(intent); }
From source file:Main.java
public static void installApkFileFromUri(Context context, Uri appPath) { Intent intent = new Intent(); intent.setDataAndType(appPath, "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }