本文整理汇总了Java中android.content.Intent.ACTION_CALL属性的典型用法代码示例。如果您正苦于以下问题:Java Intent.ACTION_CALL属性的具体用法?Java Intent.ACTION_CALL怎么用?Java Intent.ACTION_CALL使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.ACTION_CALL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemClick
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Bundle bundle = new Bundle();
String phoneNumber = ((TextView)view.findViewById(R.id.item_room)).getText().toString();
//String treatment = ((TextView)v.findViewById(R.id.item_name)).getText().toString();
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(getContext(), android.Manifest.permission.CALL_PHONE)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(getActivity(),
new String[]{android.Manifest.permission.CALL_PHONE},
MY_PERMISSIONS_REQUEST_CALL_PHONE);
// MY_PERMISSIONS_REQUEST_CALL_PHONE is an
// app-defined int constant. The callback method gets the
// result of the request.
} else {
//You already have permission
try {
startActivity(intent);
} catch(SecurityException e) {
e.printStackTrace();
}
}
startActivity(intent);
}
示例2: callPhone
/**
* 拨打电话
*/
public static void callPhone(Activity activity, String phone) {
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
PermissionUtil.applyPermission(activity, Manifest.permission.CALL_PHONE, 100);
return;
}
activity.startActivity(intent);
}
示例3: calling
public void calling() {
Log.d(TAG, "Calling");
if (!validate()) {
onCallFailed();
return;
}
_callButton.setEnabled(false);
final ProgressDialog progressDialog = new ProgressDialog(Call.this,
R.style.AppTheme_Dark_Dialog);
progressDialog.setIndeterminate(true);
progressDialog.setMessage("Залгаж байна...");
progressDialog.show();
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
onCallSuccess();
progressDialog.dismiss();
}
}, 3000);
String phoneNumber = _phoneText.getText().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phoneNumber));
startActivity(callIntent);
}
示例4: onClick
@Override
public void onClick(View view) {
String nbr = (String) view.getTag();
if (!TextUtils.isEmpty(nbr)) {
SipProfile acc = mAccountChooserButton.getSelectedAccount();
Intent it = new Intent(Intent.ACTION_CALL);
it.setData(SipUri.forgeSipUri(SipManager.PROTOCOL_CSIP, nbr));
it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
it.putExtra(SipProfile.FIELD_ACC_ID, acc.id);
startActivity(it);
}
}
示例5: cancelIfBusy
@ReactMethod
public void cancelIfBusy() {
String uri = "tel:" + Uri.encode("##67#");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}
示例6: call
/**
* сделать вызов по телефону
* необходимо разрешение на звонки на Android 6+!
*
* @param context Контекст
* @param phoneNumber номер телефона
*/
@SuppressWarnings("MissingPermission")
public static void call(Context context, @Nullable String phoneNumber) {
if (!TextUtils.isEmpty(phoneNumber)) {
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (intent.resolveActivity(context.getPackageManager()) != null) {
context.startActivity(intent);
} else {
Toast.makeText(context, R.string.error_dont_have_call_app, Toast.LENGTH_SHORT)
.show();
}
}
}
示例7: immediatePhoneCall
@ReactMethod
public void immediatePhoneCall(String number) {
number = Uri.encode(number);
String url = "tel:" + number;
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}
示例8: cancelIfNotAnswered
@ReactMethod
public void cancelIfNotAnswered() {
String uri = "tel:" + Uri.encode("##61#");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}
示例9: callPhone
public static void callPhone(Context ctx, String phoneNumber) {
if (ctx == null) {
return;
}
if (phoneNumber == null || phoneNumber.isEmpty()) {
return;
}
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
+ phoneNumber));
ctx.startActivity(intent);
}
示例10: cancelUnconditional
@ReactMethod
public void cancelUnconditional() {
String uri = "tel:" + Uri.encode("##21#");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}
示例11: cancelAllConditional
@ReactMethod
public void cancelAllConditional() {
String uri = "tel:" + Uri.encode("##002#");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}
示例12: call
private void call(int i)
{
String phone;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && checkSelfPermission(android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{android.Manifest.permission.CALL_PHONE}, PERMISSIONS_REQUEST_PHONE_CALL);
}
else{
phone = number[i];
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:+91" + phone));
startActivity(intent);
}
}
示例13: onReceive
@Override
public void onReceive(Context context, Intent intent) {
if(SipManager.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) {
PendingIntent pendingIntent = null;
String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
// We must handle that clean way cause when call just to
// get the row in account list expect this to reply correctly
if(number != null && PhoneCapabilityTester.isPhone(context)) {
// Build pending intent
Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.fromParts("tel", number, null));
pendingIntent = PendingIntent.getActivity(context, 0, i, 0);
}
// Retrieve and cache infos from the phone app
if(!sPhoneAppInfoLoaded) {
List<ResolveInfo> callers = PhoneCapabilityTester.resolveActivitiesForPriviledgedCall(context);
if(callers != null) {
for(final ResolveInfo caller : callers) {
if(caller.activityInfo.packageName.startsWith("com.android")) {
PackageManager pm = context.getPackageManager();
Resources remoteRes;
try {
// We load the resource in the context of the remote app to have a bitmap to return.
remoteRes = pm.getResourcesForApplication(caller.activityInfo.applicationInfo);
sPhoneAppBmp = BitmapFactory.decodeResource(remoteRes, caller.getIconResource());
} catch (NameNotFoundException e) {
Log.e(THIS_FILE, "Impossible to load ", e);
}
break;
}
}
}
sPhoneAppInfoLoaded = true;
}
//Build the result for the row (label, icon, pending intent, and excluded phone number)
Bundle results = getResultExtras(true);
if(pendingIntent != null) {
results.putParcelable(CallHandlerPlugin.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent);
}
results.putString(Intent.EXTRA_TITLE, context.getResources().getString(R.string.use_pstn));
if(sPhoneAppBmp != null) {
results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, sPhoneAppBmp);
}
// This will exclude next time tel:xxx is raised from csipsimple treatment which is wanted
results.putString(Intent.EXTRA_PHONE_NUMBER, number);
}
}
示例14: makePhoneCall
public static void makePhoneCall(Context context, String phoneNumber) {
if (null != phoneNumber && phoneNumber.length() > 0) {
Uri phoneUri = Uri.parse("tel:" + phoneNumber); // Could also use Uri.Builder
Intent intent = new Intent(Intent.ACTION_CALL, phoneUri);
context.startActivity(intent);
}
}
示例15: forwardCallsIfBusy
@ReactMethod
public void forwardCallsIfBusy(String phoneNumber) {
String uri = "tel:**67*" + Uri.encode(phoneNumber+"#");
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.reactContext.startActivity(intent);
}