您的位置:首页 > 移动开发 > Android开发

Android假短信(发送短信到手机系统)

2014-08-04 21:23 423 查看
首先先加入:

android.permission.WRITE_SMS

android.permission.READ_SMS

布局文件:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

</RelativeLayout>


类文件:

package com.example.jiaduanxing;

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(20000);
				// 拿到中间人
				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", "你是局长!");
				resolver.insert(uri, values);
				}catch(InterruptedException e){
					e.printStackTrace();
				}
			}
		}.start();
		
	}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: