如何在Android的棉花糖中拨打电话 [英] How to make a phone call button in Android for Marshmallow
本文介绍了如何在Android的棉花糖中拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在Android中创建呼叫按钮.我创建了一个,它可以在所有Android设备上使用,但不能在棉花糖上使用.我不知道为什么如何为Android Marshmallow创建呼叫按钮?
I'm trying to create a calling button in Android. I created one and it works in all kind of Android device but it's not working on Marshmallow. I don't know why. How to create a calling button for android Marshmallow?
这是我用于呼叫按钮的代码:
This is the code I used for the calling button :
public void button(View v) {
String number = "12354656";
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + number));
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
return;
}
startActivity(intent);
}
推荐答案
您需要在电话设置中为您的应用启用权限.在设置权限下查看
You'll need to enable permission for your app in the phone settings. Look under permissions in settings
这篇关于如何在Android的棉花糖中拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文