2
我知道這個問題已經在這裏回答了幾次,但是我遇到了一個稍微大一點的問題,因爲Android Studio給了我以前沒有遇到的錯誤(我在android編程新)。創建按鈕來撥打特定號碼 - Android Studio
的AndroidManifest.xml
我有以下代碼中:
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
裏面的java類,我有以下代碼:
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:123456789"));
startActivity(callIntent);
我的問題是,startActivity(callIntent);
是給我下面的錯誤:
然後導致的Android Studio來補充一點:然後
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:123456789"));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
startActivity(callIntent);
Android的工作室給了最後一個錯誤這是:
我不知道我做錯了,會有人請幫忙?