我有一小段代码,基本上应该在按下按钮时拨打电话。我在网上查了一下,所有的来源基本上都给出了相同的代码。但由于某种原因,这段代码不起作用。它使应用程序崩溃,但 LogCat 不显示任何内容(意味着日志完全空白)。我还应该提到,在我的清单文件中,我确实添加了以下权限
<uses-permission android:name = "andriod.permission.CALL_PHONE" />
我的代码如下。任何帮助将不胜感激!
phoneButton.setOnClickListener(new OnClickListener () {
public void onClick(View v) {
try {
final Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:232131232"));
ContactUs.this.startActivity(callIntent);
}catch (ActivityNotFoundException e){
Log.e("Dialing", "call Failed!", e);
}
}
});