Example usage for android.content Intent ACTION_DIAL

List of usage examples for android.content Intent ACTION_DIAL

Introduction

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

Prototype

String ACTION_DIAL

To view the source code for android.content Intent ACTION_DIAL.

Click Source Link

Document

Activity Action: Dial a number as specified by the data.

Usage

From source file:Main.java

public static void tell(String s, Activity activity) {
    if (!"".equals(getEmply(s))) {
        Uri uri = Uri.parse("tel:" + s);
        Intent it = new Intent(Intent.ACTION_DIAL, uri);
        activity.startActivity(it);/*  w  ww  .  j a  va  2 s.  co  m*/
    }
}

From source file:Main.java

public static void callSystemActionDial(Context context, String phone) {
    Uri uri = Uri.parse("tel:" + phone);
    Intent intent = new Intent(Intent.ACTION_DIAL, uri);
    context.startActivity(intent);//from  ww  w . j  a va2s  .  c om
}

From source file:Main.java

public static void makeCall(String phoneNumber, Context context) {
    String number = String.format("tel:%s", phoneNumber);
    Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse(number));
    context.startActivity(callIntent);//from   w  ww.ja  va  2  s.  c o m
}

From source file:Main.java

public static void dialPhone(Context context, String phoneNumber) {
    if (!TextUtils.isEmpty(phoneNumber)) {
        try {/*  w w  w  .ja v a2  s. c  o m*/
            Intent callIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
            context.startActivity(callIntent);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:Main.java

/**
 * Opens the dialer app with my number/*  www .  j  a va  2s  . co m*/
 * @param activity the calling activity
 * @param phoneNumber the phone number to call
 */
public static void openPhoneDialer(Activity activity, String phoneNumber) {
    Intent phoneIntent = new Intent(Intent.ACTION_DIAL);
    phoneIntent.setData(Uri.parse("tel:" + phoneNumber));
    activity.startActivity(phoneIntent);
}

From source file:Main.java

public static void startDialer(Context context, String phoneNumber) {
    try {//from w w w  . j av a 2s.  c  om
        Intent dial = new Intent();
        dial.setAction(Intent.ACTION_DIAL);
        dial.setData(Uri.parse("tel:" + phoneNumber));
        context.startActivity(dial);
    } catch (Exception ex) {
        Log.e(TAG, "Error starting phone dialer intent.", ex);
        Toast.makeText(context, "Sorry, we couldn't find any app to place a phone call!", Toast.LENGTH_SHORT)
                .show();
    }
}

From source file:Main.java

public static void callPhoneNumber(@NonNull Context context, @NonNull String resource) {
    //First of all, the number needs to be extracted from the resource
    String number = "";
    for (int i = 0; i < resource.length(); i++) {
        char digit = resource.charAt(i);
        if (digit >= '0' && digit <= '9') {
            number += digit;//  w w w  .ja  v  a2 s  .  c o m
        }
    }
    context.startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number)));
}

From source file:Main.java

public static Intent openDialer(String number) {
    return new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number));
}

From source file:Main.java

public static Intent getLaunchIntent(Context context, String title, String url, String sel) {
    Intent intent = null;/*from  www  .j  a  v  a2  s .  c  om*/
    String number = parseTelephoneNumber(sel);
    if (number != null) {
        intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + number));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    } else {
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (isMapsURL(url)) {
            intent.setClassName(GMM_PACKAGE_NAME, GMM_CLASS_NAME);
        } else if (isYouTubeURL(url)) {
            intent.setPackage(YT_PACKAGE_NAME);
        }

        // Fall back if we can't resolve intent (i.e. app missing)
        PackageManager pm = context.getPackageManager();
        if (null == intent.resolveActivity(pm)) {
            intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }
    }

    if (sel != null && sel.length() > 0) {
        ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        cm.setText(sel);
    }

    return intent;
}

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