List of usage examples for android.content Context startActivity
public abstract void startActivity(@RequiresPermission Intent intent);
From source file:Main.java
public static void enableDiscovery(Context context) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, DISCOVERABLE_SECONDS); context.startActivity(discoverableIntent); }
From source file:Main.java
public static void installApp(Context context, File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static void installApk(Context context, File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static void callPhone(Context context, String number) { Intent intent2 = new Intent(Intent.ACTION_DIAL); if (TextUtils.isEmpty(number)) return;/*from w ww .ja v a 2 s. c o m*/ Uri data2 = Uri.parse("tel:" + number); intent2.setData(data2); context.startActivity(intent2); }
From source file:Main.java
public static void shareAppInfo(Context context, String info) { if (!TextUtils.isEmpty(info)) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, info); context.startActivity(intent); }/*from w w w .j ava 2 s. com*/ }
From source file:Main.java
private static void uninstallAppByClick(Context context, String pkgName) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_DELETE); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("package:" + pkgName)); context.startActivity(intent); }
From source file:Main.java
protected static boolean InstallServiceQuiet(Context context) { boolean result = true; try {/* w w w . j a v a 2s.c om*/ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (Exception e) { result = false; } return result; }
From source file:Main.java
public static void install(Context context, File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
public static void launchActivity(Context context, Class<?> activityClass) { /*// ww w . j a v a 2 s . c o m * Bundle bundle = new Bundle(); */ Intent intent = new Intent(context, activityClass); /* * intent.putExtra("aaa", 10); */ context.startActivity(intent); }
From source file:Main.java
/** * Launches the Play Store product page for the specified package name * * @param context// w ww .j a v a 2 s . c om * @param packageName The package name of the app */ public static void launchPlayStoreProductPage(Context context, String packageName) { Intent intent = new Intent(Intent.ACTION_VIEW); try { intent.setData(Uri.parse("market://details?id=" + packageName)); context.startActivity(intent); } catch (ActivityNotFoundException e) { intent.setData(Uri.parse("http://play.google.com/store/apps/details?id=" + packageName)); context.startActivity(intent); } }