I follow this video tutorial Previously, It has no problems .
Today I try again , but it has some problem with it.This picture
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fooddeliverycaller">
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="24" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
</application>
You need to add (runtime) permissions check. Starting from Android API 23 and higher, you need to ask for permissions to do certain tasks(Ex: calls, location info...) during runtime. To do so, simply, click on this code:
startActivity(callIntent);
Go to the red warning triangle/sign left to your code. Click on it, and click on add permission check. Now when you run your app, a "dialog" will pop up, and ask the user to allow the app to make calls.
Hope this helps. For more info see this links:
Android permission checks
or check out this previously answered question (as suggested by @CommonsWare):
Android permission doesn't work even if I have declared it
You should use
Intent.ACTION_DIAL
instead of Intent.ACTION_CALL. Intent.ACTION_DIAL which prepopulates the dialer with the number you pass it. It doesn't require permission.
Hope it solves the problem!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With