List of usage examples for android.content Context startActivity
public abstract void startActivity(@RequiresPermission Intent intent);
From source file:Main.java
public static void playVideoOrAudio(Context context, Uri uri) { Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
public static void startActivity(Context context, Class class1, Bundle bundle) { Intent intent = new Intent(context, class1); intent.putExtras(bundle);/* w w w . j av a 2s . c o m*/ context.startActivity(intent); }
From source file:Main.java
/** * Start intent using an activity inside this app. This method is useful if you are certain * that the intent can be handled inside this app, and you care about shaving milliseconds. *///w ww. jav a2s. c om public static void startActivityInApp(Context context, Intent intent) { String packageName = context.getPackageName(); intent.setPackage(packageName); context.startActivity(intent); }
From source file:Main.java
public static boolean launchActivity(Context from, Intent intent) { if (from == null) throw new NullPointerException("from == null"); try {/*from www . jav a 2 s . co m*/ from.startActivity(intent); return true; } catch (ActivityNotFoundException e) { e.printStackTrace(); return false; } }
From source file:Main.java
private static boolean startBrowserActivity(@NonNull Context context, @NonNull String url) { try {/* w w w.ja v a 2 s . c om*/ Intent it = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); context.startActivity(it); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:Main.java
public static void uninstallApk(Context context, String pkgName) { Uri uri = Uri.parse("package:" + pkgName); Intent intent = new Intent(Intent.ACTION_DELETE, uri); context.startActivity(intent); }
From source file:Main.java
public static void goGoogleMarket(Context context) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("market://search?q=" + context.getPackageName())); context.startActivity(i); }
From source file:Main.java
public static void doIt(Context context, String number) { Intent phoneIntent = new Intent(Intent.ACTION_CALL); phoneIntent.setData(Uri.parse("tel:" + number)); context.startActivity(phoneIntent); }
From source file:Main.java
public static void jumpToSystemSetting(Context context) { Intent intent = new Intent("acton.settings.personal.ServicePhone"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }
From source file:Main.java
public static void searchContent(Context context, String content) { Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY, content); context.startActivity(intent); }