List of usage examples for android.content Intent setData
public @NonNull Intent setData(@Nullable Uri data)
From source file:org.cocos2dx.lib.CCUtils.java
public static void openUrl(String url) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); Cocos2dxActivity.getContext().startActivity(intent); }
From source file:org.cocos2dx.lib.CCUtils.java
public static void openAppInStore() { String pkg = Cocos2dxActivity.getContext().getPackageName(); String url = String.format("https://play.google.com/store/apps/details?id=%s", pkg); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); Cocos2dxActivity.getContext().startActivity(intent); }
From source file:Main.java
public static final void openGPS(Context context) { try {// w ww .j av a 2 s . c o m if (!isOpenGPS(context)) { Intent GPSIntent = new Intent(); GPSIntent.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider"); GPSIntent.addCategory("android.intent.category.ALTERNATIVE"); GPSIntent.setData(Uri.parse("custom:3")); PendingIntent.getBroadcast(context, 0, GPSIntent, 0).send(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
/** * Helper method where either the application will open the {@link Settings#ACTION_APPLICATION_DETAILS_SETTINGS} * or {@link Settings#ACTION_MANAGE_APPLICATIONS_SETTINGS} * * @param context/* w w w .j ava 2s . c om*/ * @return */ public static Intent getLaunchSettingsIntent(Context context) { Intent intent; try { // Direct the user to the application detail page where they can change the permissions. intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + context.getPackageName())); } catch (ActivityNotFoundException e) { // Fails take then to the all applications screen. intent = new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); } return intent; }
From source file:com.github.longkai.zhihu.util.Utils.java
public static void viewOnWeb(Context context, Uri uri) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(uri); context.startActivity(intent);/*ww w.j a v a2 s . c o m*/ }
From source file:com.saulcintero.moveon.osm.OSMHelper.java
public static Intent GetOsmSettingsIntent(Context ctx) { Intent intentOsm; intentOsm = new Intent(ctx.getPackageName() + ".OSM_AUTHORIZE"); intentOsm.setData(Uri.parse("moveonsportstracker://authorize")); return intentOsm; }
From source file:com.github.longkai.zhihu.util.Utils.java
/** * view user' s infomation on the web./*ww w.j ava 2 s . co m*/ * * @param context * @param id */ public static void viewUserInfo(Context context, String id) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://www.zhihu.com/people/" + id)); context.startActivity(intent); }
From source file:Main.java
public static Intent getApplicationDetailsIntent(String packageName) { Intent intent = new Intent(); final int apiLevel = Build.VERSION.SDK_INT; if (apiLevel >= 9) { // above 2.3 intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); Uri uri = Uri.fromParts(SCHEME, packageName, null); intent.setData(uri); } else { // below 2.3 final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22 : APP_PKG_NAME_21); intent.setAction(Intent.ACTION_VIEW); intent.setClassName(APP_DETAILS_PACKAGE_NAME, APP_DETAILS_CLASS_NAME); intent.putExtra(appPkgName, packageName); }/*from ww w.j ava 2 s . c o m*/ return intent; }
From source file:net.openid.appauth.AuthorizationManagementActivity.java
/** * Creates an intent to handle the completion of an authorization flow. This restores * the original AuthorizationManagementActivity that was created at the start of the flow. * @param context the package context for the app. * @param responseUri the response URI, which carries the parameters describing the response. *///www .j a v a 2 s .com public static Intent createResponseHandlingIntent(Context context, Uri responseUri) { Intent intent = createBaseIntent(context); intent.setData(responseUri); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); return intent; }
From source file:im.delight.android.baselib.Social.java
/** * Constructs an email Intent for the given message details and opens the application choooser for this Intent * * @param recipient the recipient's email address * @param subject the subject of the message * @param body the body text as a string * @param captionRes the string resource ID for the application chooser's window title * @param restrictToPackage an optional package name that the Intent may be restricted to (or null) * @param context the Context instance to start the Intent from * @throws Exception if there was an error trying to launch the email Intent *///from ww w .ja v a 2 s. c o m public static void sendMail(final String recipient, final String subject, final String body, final int captionRes, final String restrictToPackage, final Context context) throws Exception { final String uriString = "mailto:" + Uri.encode(recipient) + "?subject=" + Uri.encode(subject) + "&body=" + Uri.encode(body); final Uri uri = Uri.parse(uriString); final Intent emailIntent = new Intent(Intent.ACTION_SENDTO); emailIntent.setData(uri); if (restrictToPackage != null && restrictToPackage.length() > 0) { emailIntent.setPackage(restrictToPackage); if (context != null) { // launch the target app directly context.startActivity(emailIntent); } } else { if (context != null) { // offer a selection of all applications that can handle the email Intent context.startActivity(Intent.createChooser(emailIntent, context.getString(captionRes))); } } }