Java Code Examples for android.content.Intent.ACTION_CALL

The following are Jave code examples for showing how to use ACTION_CALL of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ForeverLibrary   File: PhoneUtil.java   View Source Code Vote up 7 votes
/**
 * 拨打电话
 */
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);
}
 
Example 2
Project: actions   File: Call.java   View Source Code Vote up 7 votes
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);
}
 
Example 3
Project: CSipSimple   File: CallLogDetailsFragment.java   View Source Code Vote up 7 votes
@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);
    }
}
 
Example 4
Project: uchimznaem-helper   File: ContactsFragment.java   View Source Code Vote up 6 votes
@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);
}
 
Example 5
Project: react-native-forward-calls   File: RNForwardCallsModule.java   View Source Code Vote up 6 votes
@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);
}
 
Example 6
Project: utils-android   File: IntentUtils.java   View Source Code Vote up 6 votes
/**
 * сделать вызов по телефону
 * необходимо разрешение на звонки на 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();
        }
    }
}
 
Example 7
Project: react-native-immediate-phone-call   File: RNImmediatePhoneCallModule.java   View Source Code Vote up 6 votes
@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);
}
 
Example 8
Project: react-native-forward-calls   File: RNForwardCallsModule.java   View Source Code Vote up 6 votes
@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);
}
 
Example 9
Project: sctalk   File: IMUIHelper.java   View Source Code Vote up 6 votes
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);
}
 
Example 10
Project: react-native-forward-calls   File: RNForwardCallsModule.java   View Source Code Vote up 6 votes
@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);
}
 
Example 11
Project: react-native-forward-calls   File: RNForwardCallsModule.java   View Source Code Vote up 6 votes
@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);
}
 
Example 12
Project: Nimbus   File: MainActivity.java   View Source Code Vote up 6 votes
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);
    }

}
 
Example 13
Project: CSipSimple   File: CallHandler.java   View Source Code Vote up 6 votes
@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);
		
	}
}
 
Example 14
Project: appinventor-extensions   File: PhoneCallUtil.java   View Source Code Vote up 6 votes
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);
  }
}
 
Example 15
Project: react-native-forward-calls   File: RNForwardCallsModule.java   View Source Code Vote up 6 votes
@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);
}
 
Example 16
Project: Happy   File: MainActivity.java   View Source Code Vote up 5 votes
protected void call(String phone) {
	Intent intent = new Intent(Intent.ACTION_CALL);
	intent.setData(Uri.parse("tel:"+phone));
	startActivity(intent);
}
 
Example 17
Project: phonk   File: Intents.java   View Source Code Vote up 5 votes
public static void call(Context c, String number) {
    Intent intent = new Intent(Intent.ACTION_CALL);
    intent.setData(Uri.parse("tel:" + number));
    c.startActivity(intent);
}
 
Example 18
Project: Tech-Jalsa   File: Calling.java   View Source Code Vote up 5 votes
private void dialNumber(String number){
    Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + number.trim()));
    startActivity(callIntent);
}
 
Example 19
Project: XERUNG   File: Comman.java   View Source Code Vote up 5 votes
public void callPhone(String number,Context context){
	 Intent callIntent = new Intent(Intent.ACTION_CALL);
     callIntent.setData(Uri.parse("tel:" + number));
	 context.startActivity(callIntent);
}
 
Example 20
Project: MVVMFrames   File: AppUtils.java   View Source Code Vote up 3 votes
/**
 * 拨打电话
 *
 * @param activity Activity
 * @param phone    电话号码
 */
public static void call(Activity activity, String phone) {
    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
    activity.startActivity(intent);
}