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(String fileName, Context context) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive"); context.startActivity(intent); }
From source file:Main.java
public static void openURL(Context ctx, String url) { Intent i2 = new Intent(Intent.ACTION_VIEW); i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i2.setData(Uri.parse(url));/*w w w . jav a 2 s. c om*/ ctx.startActivity(i2); }
From source file:Main.java
public static boolean callPhone(Context context, String phone) { try {// w ww. j a va 2 s.co m Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse("tel:" + phone)); context.startActivity(callIntent); return true; } catch (ActivityNotFoundException e) { return false; } }
From source file:Main.java
public static void goLocationSettingPage(Context context) { Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); context.startActivity(intent); // context.startActivity(new // Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS)); }
From source file:Main.java
public static void gotoActivity(Context ctx, Class<?> c, String s, boolean b, int flag) { Intent intent = new Intent(ctx, c); intent.putExtra(s, b);/* w w w . java2 s . c o m*/ intent.setFlags(flag); ctx.startActivity(intent); ((Activity) ctx).finish(); }
From source file:Main.java
public static void startActivityByPackageName(Context context, String packagename) { try {/*from w ww. j a va 2 s . com*/ Intent intent = new Intent(); intent.setPackage(packagename); context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static void call(Context cxt, String number) { String phoneUri = "tel:"; phoneUri = phoneUri.concat(number);//from w w w .j ava2s . c om Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(phoneUri)); cxt.startActivity(intent); }
From source file:Main.java
public static void launchApp(Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); Intent intent = packageManager.getLaunchIntentForPackage(packageName); context.startActivity(intent); }
From source file:Main.java
public static void accessUrl(Context context, String url) { Intent intent = new Intent(Intent.ACTION_VIEW); //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(url));/*from w w w. ja va 2 s . co m*/ context.startActivity(intent); }
From source file:Main.java
public static void callPhone(Context context, String number) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_DIAL); intent.setData(Uri.parse(String.format("tel:%s", number))); context.startActivity(intent); }