Example usage for android.content Intent setData

List of usage examples for android.content Intent setData

Introduction

In this page you can find the example usage for android.content Intent setData.

Prototype

public @NonNull Intent setData(@Nullable Uri data) 

Source Link

Document

Set the data this intent is operating on.

Usage

From source file:Main.java

/**
 * Launch Application Setting to grant permission.
 *//*from www .j a v a2 s  . c  o  m*/
public static void launchPermissionSettings(Activity activity) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
    activity.startActivity(intent);
}

From source file:Main.java

public static void scanPic(Context context, File file) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri contentUri = Uri.fromFile(file);
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

public static void launchWeb(Context activityContext, String url) {
    //Log.d(TAG, "launchWeb::"+url);
    Intent in = new Intent();
    in.setAction(Intent.ACTION_VIEW);//from  w  w w .j  a v  a 2  s .co m
    in.addCategory(Intent.CATEGORY_BROWSABLE);
    in.setData(Uri.parse(url));
    activityContext.startActivity(in);
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    if (context == null)
        return;/*from   w  w  w .  j ava  2 s. com*/
    if (TextUtils.isEmpty(packageName))
        return;
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);
    context.startActivity(intent);
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    Intent intent = new Intent("android.intent.action.DELETE");
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);
    context.startActivity(intent);// www  .  jav a 2 s.  c om
}

From source file:Main.java

public static void callSms(Context context, String number, String content) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_SENDTO);
    intent.putExtra("sms_body", content);
    intent.setData(Uri.parse(String.format("smsto:%s", number)));
    context.startActivity(intent);/*from w w  w .  ja  v a  2 s  . c  o m*/
}

From source file:Main.java

/**
 * <pre>//from   w w w .ja v  a2 s  . c  o m
 * Open other app to view URL of an app (typically browser or Google Play)
 * </pre>
 * @param downloadUrl
 */
public static void openDownloadPage(String downloadUrl) {
    Context context = getCurrentContext();
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setData(Uri.parse(downloadUrl));
    context.startActivity(intent);
}

From source file:Main.java

public static void jumpToSystemDownloadApk(Context context, String url) {
    Intent intent = new Intent("android.intent.action.VIEW");
    Uri data = Uri.parse(Html.fromHtml(url).toString());
    intent.setData(data);
    intent.setPackage("com.google.android.browser");
    intent.addCategory("android.intent.category.BROWSABLE");
    intent.setComponent(new ComponentName("com.android.browser", "com.android.browser.BrowserActivity"));
    context.startActivity(intent);//from  w  w w  .  ja v  a 2  s  .co m
}

From source file:Main.java

public static void openURL(final Context ctx, final String url) {
    final Intent i2 = new Intent(Intent.ACTION_VIEW);
    i2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    i2.setData(Uri.parse(url));
    ctx.startActivity(i2);//  w  ww .  j  a  v a2s  .  co m
}

From source file:Main.java

public static void openURL(Activity activity, String url) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse(url);//from w  ww.ja v  a2  s .  c  o m
    intent.setData(content_url);
    activity.startActivity(intent);
}