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

public static void openMyAppInfo(Context mContext) {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts(SCHEME, mContext.getPackageName(), null);
    intent.setData(uri);
    mContext.startActivity(intent);/*from  www . j  av a 2 s . co  m*/
}

From source file:Main.java

public static boolean sendEmailToDeveleper(Activity act) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri content_url = Uri.parse("https://mail.qq.com");
    intent.setData(content_url);
    act.startActivity(intent);/*from ww w  .  ja  v a  2  s  .c  o m*/
    return true;
}

From source file:Main.java

public static Intent launchEventById(long id) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri.Builder uri = Events.CONTENT_URI.buildUpon();
    uri.appendPath(Long.toString(id));
    intent.setData(uri.build());
    return intent;
}

From source file:Main.java

public static boolean gotoGoogleMarket(Activity activity, String pck) {
    try {/*  w w  w.  j  a v  a  2s  . c om*/
        Intent intent = new Intent();
        intent.setPackage("com.android.vending");
        intent.setAction(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=" + pck));
        activity.startActivity(intent);
        return true;
    } catch (Exception e) {
        e.printStackTrace();
        return false;
    }
}

From source file:Main.java

public static void uninstallApp(String packageName, Activity activity) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.DELETE");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.setData(Uri.parse("package:" + packageName));
    activity.startActivityForResult(intent, 0);
}

From source file:Main.java

public static void galleryAddPic(Context context, String path) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(path);
    Uri contentUri = Uri.fromFile(f);//from  w  w  w  . j  av  a 2 s.c om
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

public static void addNewImageToGallery(Context context, String filePath) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(filePath);
    Uri contentUri = Uri.fromFile(f);/*from  w  w  w .  ja va  2  s . c  o m*/
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

public static void callPhone(Context context, String number) {
    Intent intent2 = new Intent(Intent.ACTION_DIAL);
    if (TextUtils.isEmpty(number))
        return;// w  w w .j  av  a2  s  .c  om
    Uri data2 = Uri.parse("tel:" + number);
    intent2.setData(data2);
    context.startActivity(intent2);
}

From source file:Main.java

public static void globalAppsMediaScanIntent(Context context, String imageFullPath) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    File f = new File(imageFullPath);
    Uri contentUri = Uri.fromFile(f);//from w  w w . j  a  v  a  2s  .co  m
    mediaScanIntent.setData(contentUri);
    context.sendBroadcast(mediaScanIntent);
}

From source file:Main.java

/**
 * Forces the Android gallery to  refresh its thumbnail images.
 * @param context// ww  w  .ja  v  a2s .  c o  m
 * @param fdelete
 */
private static void refreshGalleryImages(Context context, File fdelete) {
    try {
        context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
                Uri.parse("file://" + Environment.getExternalStorageDirectory())));
    } catch (Exception e1) {
        try {
            Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
            Uri contentUri = Uri.fromFile(fdelete);
            mediaScanIntent.setData(contentUri);
            context.sendBroadcast(mediaScanIntent);
        } catch (Exception e2) {
        }
    }
}