标签:android基础
package com.examp.createsms; import android.app.Activity; import android.content.ContentResolver; import android.content.ContentValues; import android.net.Uri; import android.os.Bundle; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); new Thread() { public void run() { try { Thread.sleep(2000); // 创建内容解析器 ContentResolver resolver = getContentResolver(); // 定义调用系统短信的主机名 Uri uri = Uri.parse("content://sms/"); // 生成短信数据 ContentValues values = new ContentValues(); values.put("address", "110"); values.put("type", 1); values.put("date", System.currentTimeMillis()); values.put("body", "XXX先生您好,我们是您听说过安利吗????"); // 调用指定主机名的插入数据的方法 resolver.insert(uri, values); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }; }.start(); } }
标签:android基础
原文地址:http://blog.csdn.net/dong_martin/article/details/27357043