List of usage examples for android.content Context startActivity
public abstract void startActivity(@RequiresPermission Intent intent);
From source file:Main.java
public static void installApk(Context context, File file) { Uri packageUri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW, packageUri); intent.setDataAndType(packageUri, "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static void makeVisible(Context context, int durationSeconds) { Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, durationSeconds); context.startActivity(discoverableIntent); }
From source file:Main.java
public static void start(Context context, Class<? extends Activity> clazz, String arg1) { Intent intent = new Intent(context, clazz); Bundle bundle = new Bundle(); bundle.putString(ARG_1, arg1);/*from www . j av a2s .c o m*/ intent.putExtras(bundle); context.startActivity(intent); }
From source file:Main.java
public static boolean settings(Context context, PackageInfo packageInfo) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + packageInfo.packageName)); context.startActivity(intent); return true;/*from w w w. jav a 2 s .c o m*/ }
From source file:Main.java
public static void openActivity(Context context, Class<?> activity, Bundle b, int flags) { Intent intent = new Intent(context, activity); intent.addFlags(flags);/* www. j a v a2 s.c o m*/ if (b != null) intent.putExtras(b); context.startActivity(intent); }
From source file:Main.java
public static void install(Context context, File file) { try {/*from w w w.j av a 2 s . com*/ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
/** * Method to get more apps//ww w. ja v a2 s .c o m * * @param context * @param publisherName */ public static void getMoreApps(Context context, String publisherName) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://search?q=pub:" + publisherName)); if (isIntentAvailable(context, intent)) { context.startActivity(intent); } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
public static void startSearchPlayApplication(Context mContext, String pkgName) { try {/*from w w w. j a v a 2 s.co m*/ Intent mIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + pkgName)); mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(mIntent); } catch (android.content.ActivityNotFoundException anfe) { Intent mIntent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + pkgName)); mIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); mContext.startActivity(mIntent1); } }
From source file:Main.java
public static void editMessage(Context context, String phoneNumber, String msg) { Uri smsToUri = Uri.parse("smsto:" + phoneNumber); Intent msgIntent = new Intent(Intent.ACTION_SENDTO, smsToUri); msgIntent.putExtra("sms_body", msg); context.startActivity(msgIntent); }
From source file:Main.java
public static void shareImage(Context context, Uri uri, String title) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); shareIntent.setType("image/jpeg"); context.startActivity(Intent.createChooser(shareIntent, title)); }