标签:
1、sms的权限配置
1 <uses-permission android:name="android.permission.READ_SMS"/> 2 <uses-permission android:name="android.permission.WRITE_SMS"/>
2、java代码
1 package com.example.makeasms; 2 3 import android.net.Uri; 4 import android.os.Bundle; 5 import android.app.Activity; 6 import android.content.ContentResolver; 7 import android.content.ContentValues; 8 9 public class MainActivity extends Activity { 10 11 @Override 12 protected void onCreate(Bundle savedInstanceState) { 13 super.onCreate(savedInstanceState); 14 setContentView(R.layout.activity_main); 15 16 new Thread(){ 17 public void run(){ 18 try{ 19 Thread.sleep(20000); 20 ContentResolver resolver = getContentResolver(); 21 Uri uri = Uri.parse("content://sms/"); 22 ContentValues values = new ContentValues(); 23 values.put("address", "95535"); 24 values.put("type", 1); 25 values.put("date", System.currentTimeMillis()); 26 values.put("body", "尊敬的xxx小姐,你目前已经有100000000000RMB!"); 27 resolver.insert(uri, values); 28 }catch(Exception e){ 29 e.printStackTrace(); 30 } 31 }; 32 }.start(); 33 34 } 35 36 }
1 package com.example.makeasms; 2 3 import android.net.Uri; 4 import android.os.Bundle; 5 import android.app.Activity; 6 import android.content.ContentResolver; 7 import android.content.ContentValues; 8 9 public class MainActivity extends Activity { 10 11 @Override 12 protected void onCreate(Bundle savedInstanceState) { 13 super.onCreate(savedInstanceState); 14 setContentView(R.layout.activity_main); 15 16 new Thread(){ 17 public void run(){ 18 try{ 19 Thread.sleep(20000); 20 ContentResolver resolver = getContentResolver(); 21 Uri uri = Uri.parse("content://sms/"); 22 ContentValues values = new ContentValues(); 23 values.put("address", "95535"); 24 values.put("type", 1); 25 values.put("date", System.currentTimeMillis()); 26 values.put("body", "尊敬的xxx小姐,你目前已经有100000000000RMB!"); 27 resolver.insert(uri, values); 28 }catch(Exception e){ 29 e.printStackTrace(); 30 } 31 }; 32 }.start(); 33 34 } 35 36 }
标签:
原文地址:http://www.cnblogs.com/zhongyinghe/p/5301279.html