Java Code Examples for android.content.Intent#ACTION_DIAL

The following examples show how to use android.content.Intent#ACTION_DIAL . 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 File: MyActivity.java    From Wrox-ProfessionalAndroid-4E with Apache License 2.0 6 votes vote down vote up
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 2
Source File: CFCallNumber.java    From CordovaCallNumberPlugin with 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 3
Source File: CommunicationActions.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
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 File: BaseUiHelper.java    From BaseProject with 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 5
Source File: PhoneUtil.java    From Contacts with 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 6
Source File: ShareUtil.java    From memetastic with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 7
Source File: IntentUtils.java    From DevUtils with 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 8
Source File: CustomersFragment.java    From Woodmin with 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 9
Source File: BusinessDetailsActivity.java    From YelpQL with 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 10
Source File: TDevice.java    From Cotable with 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 11
Source File: IntentUtils.java    From sms-ticket with 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 12
Source File: TDevice.java    From Cotable with 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 13
Source File: SampleService.java    From OkDeepLink with Apache License 2.0 4 votes vote down vote up
@Action(Intent.ACTION_DIAL)
@Uri("tel:{phone}")
void startTel(@UriReplace("phone") String phone);
 
Example 14
Source File: CallSupportError.java    From arcusandroid with 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 15
Source File: BandwidthPhase3DialogFragment.java    From ETSMobile-Android2 with Apache License 2.0 4 votes vote down vote up
private void call() {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + getString(R.string.cooptel_phone_number)));
    startActivity(intent);
}
 
Example 16
Source File: SystemUtil.java    From Android with 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 17
Source File: MainActivity.java    From NYU-BusTracker-Android with Apache License 2.0 4 votes vote down vote up
@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 File: IntentUtil.java    From AndroidBasicProject with 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 File: DeviceUtils.java    From MVPArms with 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 File: SystemUtil.java    From KeyboardView with 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);
}