I know similar question has been asked before, my code was working before, and now it does not, my app is the default dialer and is also a system app, the canCurrentUserBlockNumbers(this) returns true, however always an empty cursor is returned now, any suggestion? Thank you
if (canCurrentUserBlockNumbers(this))
Toast.makeText(this, "ok", Toast.LENGTH_SHORT).show(); // I see this "OK" Toast
else
Toast.makeText(this, "KO", Toast.LENGTH_SHORT).show();
Cursor c = getContentResolver().query(BlockedNumberContract.BlockedNumbers.CONTENT_URI,
new String[]{BlockedNumberContract.BlockedNumbers.COLUMN_ID, BlockedNumberContract.BlockedNumbers.COLUMN_ORIGINAL_NUMBER,
BlockedNumberContract.BlockedNumbers.COLUMN_E164_NUMBER}, null, null, null);
TextView tv = findViewById(R.id.textviewblockednumbers);
tv.setText("ciao");
//int numElements=(c.getColumnCount();
while (c.moveToNext()) {
String name = c.getString(c.getColumnIndexOrThrow(BlockedNumberContract.BlockedNumbers.COLUMN_ORIGINAL_NUMBER));
tv.append(name);
tv.append(",");
c.close();
}
}
update for everyone interested, with another phone of the same brand (Xiaomi) the cursor is not empty and I can read blocked numbers, looks like a platform trouble