I'm trying to use ACTION_CALL intent for calling a USSD code. I have added the android.permission.PHONE_CALL to the manifest file but it doesn't work and get the permission error exception. PS: as you see there are also permissions for GPS and INTERNET and they works fine. Here are the codes:
public void onClick(View v) {
String encodedHash = Uri.encode("#");
String number = "*140*1";
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setPackage("com.android.phone");
intent.setData(Uri.parse("tel:" + number + encodedHash));
try{
startActivity(intent);
} catch(Exception ex){
Toast.makeText(getApplication(), ex.toString(), Toast.LENGTH_LONG).show();
}
}
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.PHONE_CALL" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity .......
I think you misspelled the text, change to the following: android.permission.CALL_PHONE