Reputation: 17393
Is it possible to call a phone number without using any permission in manifest.xml?
I'm usign below code, but it want to use call permission :
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + "0" + getItem(pos).getMobile()));
context.startActivity(intent);
Upvotes: 1
Views: 4611
Reputation: 63
// You Just Try it I hope its work perfectly: // Without permission android not permit you to make a call
// permission ""
val callIntent = Intent(Intent.ACTION_CALL)
callIntent.data = Uri.parse("tel:" + "8809617016205")
callIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
if (ContextCompat.checkSelfPermission(
activity!!, Manifest.permission.CALL_PHONE
) !==
PackageManager.PERMISSION_GRANTED
) {
ActivityCompat.requestPermissions(
activity!!,
arrayOf(Manifest.permission.CALL_PHONE),
0
)
} else if (ContextCompat.checkSelfPermission(
activity!!,
android.Manifest.permission.CALL_PHONE
)
== PackageManager.PERMISSION_GRANTED
) {
// Permission is granted
activity!!.startActivity(callIntent)
} else {
Toast.makeText(activity!!, "Allow Your Phone Permission", Toast.LENGTH_SHORT).show()
}
Upvotes: 0
Reputation: 832
sms
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.putExtra("address", "12125551212");
smsIntent.putExtra("sms_body","Body of Message");
startActivity(smsIntent);
call
Intent callIntent = new Intent( Intent.ACTION_CALL );
callIntent.setData( Uri.parse( "tel:" + phone ) );
startActivity( callIntent );
permissions
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SEND_SMS"/>
Upvotes: 0
Reputation: 6871
In fact, Intent.ACTION_DIAL
or Intent.VIEW
needs no any permission, it only open the dealer app. On the other hand, Intent.ACTION_CALL
will call directly and it needs call permission.
Upvotes: 2
Reputation: 346
You can open up the dialer with a phone number already typed in it -
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "0" + getItem(pos).getMobile()));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
But for you to be able to call a phone directly from a button click or something, you will need to add the permission, because if you're doing so, it means that your app is making the call, for which it needs permission from the android operating system.
Upvotes: 4