I'm trying to make a phone call but I get a force close:
private Uri phonenumbers(int groupPosition, int childPosition) {
if (groupPosition == 1 && childPosition == 1) return Uri.parse("tel:15555555555");
return null;
}
textView.setOnClickListener(new View.OnClickListener() {
public void onClick(View View) {
Uri uri = phonenumbers(groupPosition, childPosition);
Intent i = new Intent(Intent.ACTION_CALL, uri);
startActivity(i);
}
});
Any help would be appreciated.
String number = "tel:+919966626261";
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
startActivity(callIntent);
In manifest add this permission
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
or
<uses-permission android:name="android.permission.CALL_PRIVILEGED"></uses-permission>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.