android.content.Intent#ACTION_DIAL源码实例Demo

下面列出了android.content.Intent#ACTION_DIAL 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CordovaCallNumberPlugin   文件: CFCallNumber.java
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");
  }
}
 
源代码2 项目: Wrox-ProfessionalAndroid-4E   文件: MyActivity.java
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);
  }
}
 
源代码3 项目: mollyim-android   文件: CommunicationActions.java
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));
  }
}
 
源代码4 项目: YelpQL   文件: BusinessDetailsActivity.java
@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);
    }
}
 
源代码5 项目: Woodmin   文件: CustomersFragment.java
@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);
    }
}
 
源代码6 项目: DevUtils   文件: IntentUtils.java
/**
 * 获取跳至拨号界面意图
 * @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;
}
 
源代码7 项目: memetastic   文件: ShareUtil.java
/**
 * 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);
    }
}
 
源代码8 项目: Contacts   文件: PhoneUtil.java
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);
	}
}
 
源代码9 项目: BaseProject   文件: BaseUiHelper.java
/**
 * 跳转到系统拨号界面
 * @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);
}
 
源代码10 项目: Android   文件: SystemUtil.java
/**
 * 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);
}
 
源代码11 项目: arcusandroid   文件: CallSupportError.java
public void onReject (DialogInterface dialog, @NonNull Activity activity) {
    Intent callSupportIntent = new Intent(Intent.ACTION_DIAL, GlobalSetting.SUPPORT_NUMBER_URI);
    activity.startActivity(callSupportIntent);
}
 
源代码12 项目: OkDeepLink   文件: SampleService.java
@Action(Intent.ACTION_DIAL)
@Uri("tel:{phone}")
void startTel(@UriReplace("phone") String phone);
 
源代码13 项目: sms-ticket   文件: IntentUtils.java
/**
 * 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;
}
 
源代码14 项目: Cotable   文件: TDevice.java
public static void openDail(Context context) {
    Intent intent = new Intent(Intent.ACTION_DIAL);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
源代码15 项目: Cotable   文件: TDevice.java
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);
}
 
private void call() {
    Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + getString(R.string.cooptel_phone_number)));
    startActivity(intent);
}
 
源代码17 项目: NYU-BusTracker-Android   文件: MainActivity.java
@SuppressWarnings("UnusedParameters")
public void callSafeRide(View view) {
    Intent callIntent = new Intent(Intent.ACTION_DIAL);
    callIntent.setData(Uri.parse("tel:12129928267"));
    startActivity(callIntent);
}
 
源代码18 项目: AndroidBasicProject   文件: IntentUtil.java
/** 进入拨号界面 */
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);
}
 
源代码19 项目: MVPArms   文件: DeviceUtils.java
/**
 * 拨打电话
 *
 * @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);
}
 
源代码20 项目: KeyboardView   文件: SystemUtil.java
/**
 * 携带电话号码跳转到拨号界面
 *
 * @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);
}
 
 方法所在类
 同类方法