安卓做短线删除 这个uri 是不是有些手机不适用?content://sms/conversations/ 谢

Android 码拜 8年前 (2016-06-07) 1139次浏览
做短线删除,但是有些手机无法删除(华为荣耀3c  摩托罗拉。) 莫非这个uri有些手机不适用content://sms/conversations/
代码如下,求高手指点,在线等,谢谢!
后面的注释是本人debug的内容,用华为3c的时候uri 下面的length为0  短信删除失败   用别的手机都是为1, 成功。 这个uri有问题?

	listView.setOnItemLongClickListener(new OnItemLongClickListener() {
			@Override
			public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
					int arg2, long arg3) {
				SmsThreadBean cb = (SmsThreadBean) arg0.getItemAtPosition(arg2); //thread_id=193, date=1409294307158, snippet=【碧欧泉】对抗岁月侵袭,夜间也需专属呵护?全新碧欧泉蓝源夜间精油凝露9/1重磅上市!融合精油滋养力+精华渗透性,首创夜间精油凝露,数量有限,赠完即止!回TD退订, phoneNums=[10690029619532], contactNames=[null], message_count=1
				SMSBean smsb = new SMSBean();   //短信内容的bean
				smsb.setThread_id(cb.thread_id + "");
				smsb.setContact_name(cb.contactNames[0]);
				smsb.setAddress(cb.phoneNums[0]);
				// smsb:thread_id=193, msg_count=null, msg_snippet=null, address=10690029619532, contact_name=null, date=null, read=null
				if (smsb.getContact_name() == null|| "".equals(smsb.getContact_name())) {
					smsb.setContact_name(cb.phoneNums[0]);
					//thread_id=193, msg_count=null, msg_snippet=null, address=10690029619532, contact_name=10690029619532, date=null, read=null
				}
				showContactDialog(lianxiren1, smsb, arg2);
				return false;
			}

		});
	private String[] lianxiren1 = new String[] { "删除" };
	private void showContactDialog(final String[] arg, final SMSBean sms,
			final int position) {
		new AlertDialog.Builder(this).setTitle(sms.getContact_name()).setItems(arg, new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						long id = Long.valueOf(sms.getThread_id());    //193
						Uri uri = Uri.parse("content://sms/conversations/" + id); //content://sms/conversations/193
						int length = context.getContentResolver().delete(uri,null, null); 	//0
						if (length!= 0) {
							queryMsgs();
						}
						adapter.notifyDataSetChanged();
					}
				}).show();
解决方案

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明安卓做短线删除 这个uri 是不是有些手机不适用?content://sms/conversations/ 谢
喜欢 (0)
[1034331897@qq.com]
分享 (0)