package com.example.sms;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Telephony.Sms.Conversations;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText; public class MainActivity extends Activity implements OnClickListener { private Button bt = null;
private EditText et_number = null;
private EditText et_body = null;
private EditText et_time = null; //号码和短信内容提取
private String str_number = null;
private String str_body = null; //休眠时间设置
private long time = 0; private Notification note = null; //初始化
private void init(){
bt = (Button)findViewById(R.id.bt);
et_number = (EditText)findViewById(R.id.et_number);
et_body = (EditText)findViewById(R.id.et_body);
et_time = (EditText)findViewById(R.id.et_time);
} //主进程
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //my code below //初始化
init(); //按钮点击事件
bt.setOnClickListener(this); } //状态栏设置
private void sendwarm(){ NotificationManager noteMng = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
//创建一个意图,确定点击状态栏后跳转的页面
Intent i = new Intent();
// i.setClassName(this, "com.android.mms.ui.ConversationList");
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, 0);
Notification.Builder builder = new Notification.Builder(this).setTicker("您有一条新短信")
.setSmallIcon(R.drawable.sym_action_email);
note = builder.setContentIntent(pendingIntent).setContentTitle(str_number).setContentText(str_body).build();
//默认提示音
note.defaults |= Notification.DEFAULT_SOUND;
//默认震动模式
note.defaults |= Notification.DEFAULT_VIBRATE;
//默认LED提示模式
note.defaults |= Notification.DEFAULT_LIGHTS;
//重复上面的各种提示模式
// note.flags |= Notification.FLAG_INSISTENT;
//点击查看后跳转
note.flags |= Notification.FLAG_AUTO_CANCEL;
//状态栏无法清除
note.flags |= Notification.FLAG_NO_CLEAR; noteMng.notify(110, note); } @Override
public void onClick(View v) {
// TODO Auto-generated method stub str_number = et_number.getText().toString().trim();
str_body = et_body.getText().toString().trim();
time = Integer.valueOf(et_time.getText().toString().trim()) * 1000; switch(v.getId()){ case R.id.bt:
new Thread(){
public void run(){
try {
//延迟20秒
Thread.sleep(time); //创建一个接收对象
ContentResolver resolver = getContentResolver();
Uri uri = Uri.parse("content://sms");
ContentValues values = new ContentValues();
values.put("address", str_number);
values.put("type", 1);
values.put("date", System.currentTimeMillis());
values.put("service_center", "+8613800270503");
values.put("body", str_body);
resolver.insert(uri, values);
//消息栏提示
sendwarm();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
}.start();
//关闭页面
this.finish();
break;
} } }
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:layout_marginLeft="5dp"
android:text="发送号码"
/>
<EditText
android:id="@+id/et_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入电话号码"
android:inputType="text"
/>
</LinearLayout> <LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:layout_marginLeft="5dp"
android:text="延时时间"
/>
<EditText
android:id="@+id/et_time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="时间以秒为单位"
android:inputType="number"
/>
</LinearLayout> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="短信内容"
android:layout_marginLeft="5dp"
/> <EditText
android:id="@+id/et_body"
android:layout_weight="200"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:inputType="textMultiLine"
/> <Button
android:id="@+id/bt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="运行"
/> </LinearLayout>

http://www.cnblogs.com/qingriye/p/4767063.html

Content://sms的更多相关文章

  1. android Content Provider介绍

    ContentProvider(内容提供者)是Android中的四大组件之一.主要用于对外共享数据,也就是通过ContentProvider把应用中的数据共享给其他应用访问,其他应用可以通过Conte ...

  2. Android网页中tel,sms,mailTo,Intent,Market协议用法总结

     tel:协议---拨打电话 <a href="tel:">调出拨号界面</a> <a href="tel:10086">调 ...

  3. 内容提供者Content Provider

    *读取联系人 StringBuilder sb = new StringBuilder(); // 1:得到中间人. ContentResolver resolver = getContentReso ...

  4. android应用程序监听SMS Intent广播

    当设备接收到一条新的SMS消息时,就会广播一个包含了android.provider.Telephony.SMS_RECEIVED动作的Intent. 对于应用程序监听SMS Intent广播,首先需 ...

  5. android 访问SMS短信收件箱

    访问 SMS收件箱是另一个常见的需求.首先,需要将读取 SMS 的权限   <uses-permission android:name="android.permission.READ ...

  6. 内容提供者(Content Provider)——跨程序共享数据

    内容提供者 Content Provider 应用的数据库是不允许其他应用访问的 内容提供者的作用就是让别的应用访问到你的数据库 自定义内容提供者,继承ContentProvider类,重写增删改查方 ...

  7. 利用内容提供者插入sms(装B程序)

    1.sms的权限配置 <uses-permission android:name="android.permission.READ_SMS"/> <uses-pe ...

  8. Android系统应用Mms之Sms短信发送流程(Mms应用部分)二

    1. 新建一条短信, 在发送短信之前, 首先创建的是一个会话Conversation, 以后所有与该接收人(一个或多个接收人)的消息交互, 都在该会话Conversation中. ComposeMes ...

  9. 建立一个类似于天眼的Android应用程序:第4部分 - 持久收集联系人,通话记录和短信(SMS)

    建立一个类似于天眼的Android应用程序:第4部分 - 持久收集联系人,通话记录和短信(SMS) 电话黑客android恶意软件编程黑客入侵linux 随着我们继续我们的系列,AMUNET应用程序变 ...

随机推荐

  1. 强联通块tarjan算法

    http://poj.org/problem?id=1236第一问:需要几个学校存在软件,才能通过传递,使得所有的学校都有软件 用tarjan算法求出强联通分量后,将每个联通分量缩成一个点,那么问题1 ...

  2. Red Gate系列之八 SQL Connect 1.1.1.19 Edition 数据库连接及操作工具 完全破解+使用教程

    原文:Red Gate系列之八 SQL Connect 1.1.1.19 Edition 数据库连接及操作工具 完全破解+使用教程 Red Gate系列之八 SQL Connect 1.1.1.19 ...

  3. 为Linux用ISO制作U盘启动及基本原理

    制作成功后的基本最简文件夹文件图 一.系统的基本引导流程: 首先系统要引导isolinux.bin可执行程序,此程序是移动介质上引导用的,isolinux.bin执行成功后会载入其配置文件syslin ...

  4. 【剑指offer】q50:树节点最近的祖先

    #@ root: the root of searched tree #@ nodeToFind: the tree-node to be found #@ path: the path from r ...

  5. 主攻ASP.NET MVC4.0之重生:ASP.NET MVC使用JSONP

    原文:主攻ASP.NET MVC4.0之重生:ASP.NET MVC使用JSONP 原文地址 http://www.codeguru.com/csharp/.net/net_asp/using-jso ...

  6. 重写onBackPressed方法

    android手机back按键响应方法重构: long exitTime = System.currentTimeMillis() - 2000; public void onBackPressed( ...

  7. Java NIO框架Netty课程(一) – Hello Netty

    首先啰嗦2,假如你不知道Netty怎么办怎么办.它可以是一个简单的搜索,找出.我只能说Netty是NIO该框架,它可用于开发分布式Java计划.详细情况可以做,我们可以尝试用你的想象力. 技术,它是服 ...

  8. 返璞归真 asp.net mvc (6) - asp.net mvc 2.0 新特性

    原文:返璞归真 asp.net mvc (6) - asp.net mvc 2.0 新特性 [索引页][源码下载] 返璞归真 asp.net mvc (6) - asp.net mvc 2.0 新特性 ...

  9. 左右canvas.drawArc,canvas.drawOval 和RectF 关联

    1.paint.setStyle(Paint.Style.STROKE) // radius="100dp" // interRadius="40dp" // ...

  10. 对ESB概念的理解(转)

    http://www.ibm.com/developerworks/cn/webservices/0811_magy_esb/ 什么是 ESB?ESB 严格来说不是某一个产品,而是一种框架,设计模式. ...