Java Code Examples for android.content.Intent#ACTION_DIAL

The following examples show how to use android.content.Intent#ACTION_DIAL . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: CordovaCallNumberPlugin   File: CFCallNumber.java    License: MIT License 6 votes vote down vote up
private void callPhone(JSONArray args) throws JSONException {
  String number = args.getString(0);
  number = number.replaceAll("#", "%23");

  if (!number.startsWith("tel:")) {
    number = String.format("tel:%s", number);
  }
  try {
    boolean bypassAppChooser = Boolean.parseBoolean(args.getString(1));
    boolean enableTelephony = isTelephonyEnabled();

    Intent intent = new Intent(enableTelephony? (bypassAppChooser? Intent.ACTION_DIAL : Intent.ACTION_CALL) : Intent.ACTION_VIEW);
   
    intent.setData(Uri.parse(number));

    if ((enableTelephony==false) && bypassAppChooser) {
      intent.setPackage(getDialerPackage(intent));
    }

    cordova.getActivity().startActivity(intent);
    callbackContext.success();
  } catch (Exception e) {
    callbackContext.error("CouldNotCallPhoneNumber");
  }
}
 
Example 2
private void listing6_2() {
  // Listing 6-2: Implicitly starting an Activity
  if (somethingWeird && itDontLookGood) {
    // Create the implicit Intent to use to start a new Activity.
    Intent intent =
      new Intent(Intent.ACTION_DIAL, Uri.parse("tel:555-2368"));

    // Check if an Activity exists to perform this action.
    PackageManager pm = getPackageManager();
    ComponentName cn = intent.resolveActivity(pm);
    if (cn == null) {
      // There is no Activity available to perform the action
      // Log an error and modify app behavior accordingly,
      // typically by disabling the UI element that would allow
      // users to attempt this action.
      Log.e(TAG, "Intent could not resolve to an Activity.");
    }
    else
      startActivity(intent);
  }
}
 
Example 3
private static void startInsecureCallInternal(@NonNull Activity activity, @NonNull Recipient recipient) {
  try {
    Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + recipient.requireSmsAddress()));
    activity.startActivity(dialIntent);
  } catch (ActivityNotFoundException anfe) {
    Log.w(TAG, anfe);
    Dialogs.showAlertDialog(activity,
                            activity.getString(R.string.ConversationActivity_calls_not_supported),
                            activity.getString(R.string.ConversationActivity_this_device_does_not_appear_to_support_dial_actions));
  }
}
 
Example 4
Source Project: YelpQL   File: BusinessDetailsActivity.java    License: MIT License 5 votes vote down vote up
@OnClick(R.id.tvPhoneNumber)
void openRestaurantPhoneNo(View view) {
    if (business != null) {
        Intent i = new Intent(Intent.ACTION_DIAL);
        i.setData(Uri.fromParts("tel", business.getPhone(), null));
        startActivity(i);
    }
}
 
Example 5
Source Project: Woodmin   File: CustomersFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void makeACall(Customer customer) {
    if(customer.getBillingAddress() != null){
        Intent callIntent = new Intent(Intent.ACTION_DIAL);
        callIntent.setData(Uri.parse("tel:" + customer.getBillingAddress().getPhone()));
        startActivity(callIntent);
    }
}
 
Example 6
Source Project: DevUtils   File: IntentUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 获取跳至拨号界面意图
 * @param phoneNumber 电话号码
 * @param isNewTask   是否开启新的任务栈
 * @return 跳至拨号界面意图
 */
public static Intent getDialIntent(final String phoneNumber, final boolean isNewTask) {
    try {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
        return getIntent(intent, isNewTask);
    } catch (Exception e) {
        LogPrintUtils.eTag(TAG, e, "getDialIntent");
    }
    return null;
}
 
Example 7
/**
 * Call telephone number.
 * Non direct call, opens up the dialer and pre-sets the telephone number. User needs to press manually.
 * Direct call requires M permission granted, also add permissions to manifest:
 * <uses-permission android:name="android.permission.CALL_PHONE" />
 *
 * @param telNo      The telephone number to call
 * @param directCall Direct call number if possible
 */
@SuppressWarnings("SimplifiableConditionalExpression")
public void callTelephoneNumber(final String telNo, final boolean... directCall) {
    Activity activity = greedyGetActivity();
    if (activity == null) {
        throw new RuntimeException("Error: ShareUtil::callTelephoneNumber needs to be contstructed with activity context");
    }
    boolean ldirectCall = (directCall != null && directCall.length > 0) ? directCall[0] : true;


    if (android.os.Build.VERSION.SDK_INT >= 23 && ldirectCall && activity != null) {
        if (ContextCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.CALL_PHONE}, 4001);
            ldirectCall = false;
        } else {
            try {
                Intent callIntent = new Intent(Intent.ACTION_CALL);
                callIntent.setData(Uri.parse("tel:" + telNo));
                activity.startActivity(callIntent);
            } catch (Exception ignored) {
                ldirectCall = false;
            }
        }
    }
    // Show dialer up with telephone number pre-inserted
    if (!ldirectCall) {
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", telNo, null));
        activity.startActivity(intent);
    }
}
 
Example 8
Source Project: Contacts   File: PhoneUtil.java    License: MIT License 5 votes vote down vote up
public static void openDialActivity(Context context, String phoneNumber)
{
	try
	{
		Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
		context.startActivity(intent);
	}
	catch (ActivityNotFoundException activityException)
	{
		Log.d("PhoneUtil", "openDialActivity: ", activityException);
	}
}
 
Example 9
Source Project: BaseProject   File: BaseUiHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 跳转到系统拨号界面
 * @param context
 * @param toDialTelNo
 */
public static void jumpToSystemDialUi(Context context, String toDialTelNo) {
    Intent startIntent = new Intent(Intent.ACTION_DIAL);
    if (!Util.isEmpty(toDialTelNo)) {
        startIntent.setData(Uri.parse("tel:" + toDialTelNo));
    }
    jumpToActivity(context, startIntent, 0, false);
}
 
Example 10
Source Project: Android   File: SystemUtil.java    License: MIT License 4 votes vote down vote up
/**
 * Phone call
 * @param phonenum
 */
public static void callPhone(Context context, String phonenum) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phonenum));
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example 11
Source Project: arcusandroid   File: CallSupportError.java    License: Apache License 2.0 4 votes vote down vote up
public void onReject (DialogInterface dialog, @NonNull Activity activity) {
    Intent callSupportIntent = new Intent(Intent.ACTION_DIAL, GlobalSetting.SUPPORT_NUMBER_URI);
    activity.startActivity(callSupportIntent);
}
 
Example 12
Source Project: OkDeepLink   File: SampleService.java    License: Apache License 2.0 4 votes vote down vote up
@Action(Intent.ACTION_DIAL)
@Uri("tel:{phone}")
void startTel(@UriReplace("phone") String phone);
 
Example 13
Source Project: sms-ticket   File: IntentUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Creates Intent for calling a phone.
 */
public static Intent createCallPhoneIntent(String phoneNumber) {
    Intent callIntent = new Intent(Intent.ACTION_DIAL);
    callIntent.setData(Uri.parse("tel:" + phoneNumber));
    return callIntent;
}
 
Example 14
Source Project: Cotable   File: TDevice.java    License: Apache License 2.0 4 votes vote down vote up
public static void openDail(Context context) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example 15
Source Project: Cotable   File: TDevice.java    License: Apache License 2.0 4 votes vote down vote up
public static void openDial(Context context, String number) {
    Uri uri = Uri.parse("tel:" + number);
    Intent it = new Intent(Intent.ACTION_DIAL, uri);
    context.startActivity(it);
}
 
Example 16
private void call() {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + getString(R.string.cooptel_phone_number)));
    startActivity(intent);
}
 
Example 17
@SuppressWarnings("UnusedParameters")
public void callSafeRide(View view) {
    Intent callIntent = new Intent(Intent.ACTION_DIAL);
    callIntent.setData(Uri.parse("tel:12129928267"));
    startActivity(callIntent);
}
 
Example 18
Source Project: AndroidBasicProject   File: IntentUtil.java    License: MIT License 4 votes vote down vote up
/** 进入拨号界面 */
public static void dial(@NonNull Context context, @NonNull String phoneNumber) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example 19
Source Project: MVPArms   File: DeviceUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 拨打电话
 *
 * @param context
 * @param number
 */
public static void openDial(Context context, String number) {
    Uri uri = Uri.parse("tel:" + number);
    Intent it = new Intent(Intent.ACTION_DIAL, uri);
    context.startActivity(it);
}
 
Example 20
Source Project: KeyboardView   File: SystemUtil.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 携带电话号码跳转到拨号界面
 *
 * @param context
 * @param phoneNumber
 */
public static void actionDial(Context context, String phoneNumber) {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phoneNumber));
    context.startActivity(intent);
}