[英]Android can't read blocked numbers anymore
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?我知道以前有人问过类似的问题,我的代码以前可以工作,现在不行了,我的应用程序是默认拨号程序,也是系统应用程序,canCurrentUserBlockNumbers(this) 返回 true,但是现在总是返回一个空的 cursor ,有什么建议吗? 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更新给大家感兴趣,用同品牌的另一部手机(小米) cursor 不为空,我可以读取被阻止的号码,看起来像一个平台问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.