Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Android os >= 5.0 (sdk >= 19) #1 #2

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ android {
compileSdkVersion 27

defaultConfig {
minSdkVersion 23
minSdkVersion 19
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand Down
14 changes: 10 additions & 4 deletions android/src/main/java/sk/fourq/calllog/CallLogPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import android.provider.CallLog;
import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel;
Expand Down Expand Up @@ -49,11 +51,15 @@ public void onMethodCall(MethodCall c, Result r) {
request = c;
result = r;

if (PackageManager.PERMISSION_GRANTED == registrar.activity().checkSelfPermission(Manifest.permission.READ_CALL_LOG)) {
handleCall();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (PackageManager.PERMISSION_GRANTED == registrar.activity().checkSelfPermission(Manifest.permission.READ_CALL_LOG)) {
handleCall();
} else {
String[] perm = {Manifest.permission.READ_CALL_LOG};
registrar.activity().requestPermissions(perm, 0);
}
} else {
String[] perm = {Manifest.permission.READ_CALL_LOG};
registrar.activity().requestPermissions(perm, 0);
handleCall();
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ android {

defaultConfig {
applicationId "sk.fourq.calllogexample"
minSdkVersion 23
minSdkVersion 19
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down