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 CallPhone(Context context, String phone) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    Uri data = Uri.parse("tel:" + phone);
    intent.setData(data);
    context.startActivity(intent);/*from   w  w w . ja  v a  2 s  .  c om*/
}

From source file:Main.java

public static boolean settings(Context context, PackageInfo packageInfo) {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.setData(Uri.parse("package:" + packageInfo.packageName));
    context.startActivity(intent);//from w ww. ja  v a2s  .co  m
    return true;
}

From source file:Main.java

public static boolean isGooglePlayInstalled(Context ctx) {
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://search?q=foo"));
    PackageManager pm = ctx.getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(intent, 0);
    if (list.size() > 0) {
        return true;
    } else {//from  w  ww .  j av  a  2s.com
        return false;
    }
}

From source file:Main.java

public static void openAppInfo(Context context, String packageName) {
    Intent intent = new Intent();
    intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS");
    intent.setData(Uri.parse("package:" + packageName));
    context.startActivity(intent);// w w  w  .  j  a  v a 2s.co  m
}

From source file:Main.java

public static void uninstallApk(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri data = Uri.parse("package:" + packageName);
    intent.setData(data);
    context.startActivity(intent);//  www .  java2  s . co m
}

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));
    context.startActivity(intent);//from   w  w  w.  ja  v  a 2 s .co  m
}

From source file:Main.java

public static void refreshGallery(Context context, Uri uri) {
    Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    final Uri contentUri = uri;
    scanIntent.setData(contentUri);
    context.sendBroadcast(scanIntent);//from w w  w.  ja  va 2s. com
}

From source file:Main.java

/**
 * Open Play Store application or its web version if no play store
 * available.//from   w  w  w.  j  a va2s .  c  om
 * 
 * @param c : Android Context
 */
public static void actionDisplayPlayStore(Context c) {
    // Retrieve list of application that understand market Intent
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("market://details?id=org.alfresco.mobile.android.application"));
    final PackageManager mgr = c.getPackageManager();
    List<ResolveInfo> list = mgr.queryIntentActivities(intent, 0);

    // By default we redirect to the webbrowser version of play store.
    intent = new Intent(Intent.ACTION_VIEW);
    intent.setData(Uri.parse("https://play.google.com/"));

    for (ResolveInfo resolveInfo : list) {
        // If we find something related to android we open the application
        // version of play store.
        if (resolveInfo.activityInfo.applicationInfo.packageName.contains("android")) {
            intent.setComponent(new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName,
                    resolveInfo.activityInfo.name));
            intent.setData(Uri.parse("market://"));
            break;
        }
    }
    c.startActivity(intent);
}

From source file:Main.java

public static void goDial(Context context, String dial_number) {
    Intent phonepassIntent = new Intent();
    phonepassIntent.setAction(Intent.ACTION_DIAL);
    phonepassIntent.setData(Uri.parse("tel:" + dial_number));
    context.startActivity(phonepassIntent);
}

From source file:Main.java

private static void addTomMediaScanner(Context context, Uri uri) {
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    mediaScanIntent.setData(uri);
    context.sendBroadcast(mediaScanIntent);
}