Ich gab die READ_SMS
sowie READ_CALL_LOG
Erlaubnis in Manifest-Datei, aber immer noch bekomme ich SecurityException
in meinem BroadcastReceiver
.Permission Fehler in BroadcastReceiver
Code:
@Override
public void onReceive(Context context, Intent intent) {
getMissedCallCount(context);
getUnreadSMSCount(context);
}
private void getMissedCallCount(Context context) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_CALL_LOG) != PackageManager.PERMISSION_GRANTED) {
Log.d("Call Logs permission", "Not provided...");
return;
}
String[] projection = {CallLog.Calls.CACHED_NAME, CallLog.Calls.CACHED_NUMBER_LABEL, CallLog.Calls.TYPE};
String where = CallLog.Calls.TYPE + "=" + CallLog.Calls.MISSED_TYPE;
Cursor c = context.getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, where, null, null);
c.moveToFirst();
Log.d("CALL COUNT: ", ""+c.getCount());
c.close();
}
Log:
Call Logs permission: Not provided...
Jede Idee zu diesem Problem? Hier
Geben Sie nicht READ_SMS aber READ_CALL_LOG Erlaubnis in manifest (Sie haben read_sms Erlaubnis in manifest hinzugefügt, aber in Laufzeitprüfung read_call_log Erlaubnis, bekam es? Dort sind Berechtigungen von verschiedenen Gruppen). Und wenn Sie READ_SMS Erlaubnis benötigen, dann sollten Sie es anfordern: https://developer.android.com/training/permissions/requesting.html https://developer.android.com/guide/topics/security/permissions.html # normal-gefährlich – krossovochkin
Ich gab beide die Berechtigungen. Bitte sehen Sie meine bearbeitete Frage. – Satheshkumar
@Satheshkumar lesen [this] (https://developer.android.com/guide/topics/security/permissions.html) vollständig. – Gattsu