对话框创建:
stratified
此功能可删除完整的对话,但不起作用。
private AlertDialog AskOption()
{
AlertDialog myQuittingDialogBox =new AlertDialog.Builder(this)
.setTitle("Security Alert")
.setMessage("Do you want to delete conversation?")
.setIcon(R.drawable.d)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
SharedPreferences xsx = getApplicationContext().getSharedPreferences("ll", Context.MODE_PRIVATE);
nmr = xsx.getString("nmr", "");
removeMessage();
// removeMessage(getApplicationContext(),nmr);
delete_thread(nmr);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.create();
return myQuittingDialogBox;
}
这是另一个删除特定号码的短信会话的功能,但它也无法正常工作...我也被授予权限,我不知道自己在哪里弄错。
private void removeMessage() {
Uri uriSMSURI = Uri.parse("content://sms");
Cursor cur = getApplicationContext().getContentResolver().query(uriSMSURI, null, null, null,null);
String phoneNo, msg;
if (cur.moveToFirst()) {
String pid = cur.getString(1);
// do some process
Toast.makeText(getApplicationContext(), pid, Toast.LENGTH_LONG).show();
Cursor cur2 = getApplicationContext().getContentResolver().query(Uri.parse("content://sms/conversations/" + pid), null, null, null, null);
if (cur2.moveToFirst()) {
////Tried with this with no luck, its Delete the whole Conversation :
String pid2 = cur2.getString(1);
String uri = "content://sms/conversations/" + pid2;
getApplicationContext().getContentResolver().delete(Uri.parse(uri), null, null);
}
}
}
我尝试了这里提供的几乎所有解决方案,但没有一个起作用。