我已经尝试了所有可能的方法。但是
context.getContentResolver()。delete(Uri.parse(“ content:// sms /” + thread_id)始终返回零。请为此解决方案。 注意:清单中已授予所有必要的权限。
答案 0 :(得分:0)
实现运行时权限以读写SMS收件箱,因为(在棉花糖上方)您需要运行时权限才能执行任何系统任务
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
takeRunTimePermission();
}
public void takeRunTimePermission() {
ActivityCompat.requestPermissions(this,
new String[]{ Manifest.permission.READ_SMS},
1);
}
@Override
public void onRequestPermissionsResult(int requestCode,
String permissions[], int[] grantResults) {
switch (requestCode) {
case 1: {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// permission was granted, yay! Do the
} else {
// permission denied, boo! Disable the
Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
}
return;
}
// permissions this app might request
}
}