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 openSourceURL(Activity activity, String title, String url) {
    Intent intent = new Intent(Intent.ACTION_VIEW);
    Uri uri = Uri.parse(url);// w w  w  .j  a  v  a2  s . c  om
    intent.setData(uri);
    activity.startActivity(Intent.createChooser(intent, title));
}

From source file:Main.java

public static List<ResolveInfo> getBrowsers(Context context) {
    PackageManager pm = context.getPackageManager();

    Intent query = new Intent();
    query.setAction(Intent.ACTION_VIEW);
    query.setData(Uri.parse("http://localhost"));

    return pm.queryIntentActivities(query, 0);
}

From source file:Main.java

public static boolean openURL(String url) {
    boolean ret = false;
    try {/*ww  w  .j a v a2s  . com*/
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        sActivity.startActivity(i);
        ret = true;
    } catch (Exception e) {
    }
    return ret;
}

From source file:Main.java

public static void disImage(Activity act, File file) {
    Intent itt = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    itt.setData(Uri.fromFile(file));
    act.sendBroadcast(itt);/*from  ww w  . ja v  a2 s.c o m*/

    Intent it = new Intent(Intent.ACTION_VIEW);
    it.setDataAndType(Uri.parse(file.getPath()), "image/*");
    act.startActivity(it);
}

From source file:Main.java

/**
 * uninstall app via package name//from w  ww  .j a v  a 2 s .  c  om
 * @param context
 * @param packageName
 */
public static void uninstallApp(Context context, String packageName) {
    Uri packageUri = Uri.parse("package:" + packageName);
    Intent intent = new Intent();
    intent.setAction(Intent.ACTION_DELETE);
    intent.setData(packageUri);
    context.startActivity(intent);
}

From source file:Main.java

public static void startAttention(Context context, String s) {
    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    intent.setData(Uri.parse(s));
    intent.setClassName("com.tencent.mm", "com.tencent.mm.ui.qrcode.GetQRCodeInfoUI");
    context.startActivity(intent);/*  w  w w.  ja v  a2  s.  c o  m*/
}

From source file:Main.java

/**
 * Checks if there is any Pay by Bank app enabled CFI App installed on the device.
 *
 * @param context The context to use.//from w w w.j  a  va  2s.c om
 * @return True if there is at least one PBBA enabled CFI App available, false otherwise.
 * @see #openBankingApp(Context, String)
 */
public static boolean isCFIAppAvailable(@NonNull final Context context) {

    //noinspection ConstantConditions
    if (context == null) {
        throw new IllegalArgumentException("context == null");
    }

    final Intent zappIntent = new Intent();
    zappIntent.setData(new Uri.Builder().scheme(ZAPP_SCHEME).build());
    zappIntent.setAction(Intent.ACTION_VIEW);
    final ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(zappIntent,
            PackageManager.MATCH_DEFAULT_ONLY);
    return resolveInfo != null;
}

From source file:Main.java

public static void shareViaEmail(Context context, String subject, String text) {
    Intent intent = new Intent(Intent.ACTION_SENDTO);
    intent.setType("text/html");
    intent.setData(Uri.parse("mailto:"));
    intent.putExtra(Intent.EXTRA_TEXT, text);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    context.startActivity(Intent.createChooser(intent, "Share via Email"));
}

From source file:Main.java

public static void mail(Activity activity, String subject, String text, String mail) {

    Intent intent = new Intent();

    intent.setAction(Intent.ACTION_SENDTO);
    intent.setData(Uri.parse("mailto:" + mail));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, text);

    activity.startActivity(intent);/*from w  w w. ja  v  a  2  s. c o  m*/

}

From source file:Main.java

/**
 * send a message  to call the emergency with location of the accident
 *
 * @param latitude//from   www . j  a va2 s . com
 * @param longitude
 */
public static void sendEmergencyToMessages(double latitude, double longitude, Context context) {
    Intent sendSmsIntent = new Intent(Intent.ACTION_VIEW);
    sendSmsIntent.setData(Uri.parse("sms:"));
    sendSmsIntent.setType("vnd.android-dir/mms-sms");
    String message = "The Car had accident at: " + latitude + " , " + longitude;
    sendSmsIntent.putExtra(Intent.EXTRA_TEXT, message);
    if (sendSmsIntent.resolveActivity(context.getPackageManager()) != null) {
        context.startActivity(sendSmsIntent);
    }
}