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. Android源代码下载之《Android新闻client源代码》

    介绍 Android新闻client源代码,功能上分为:新闻.关注.读报.微博.里面比較有特色的就是读报功能.真正安装报纸的排版进行读报.给人得感觉就像是在读真实的报纸.事实上即使首页的动态云标签很有 ...

  2. 重新想象 Windows 8 Store Apps (6) - 控件之媒体控件: Image, MediaElement

    原文:重新想象 Windows 8 Store Apps (6) - 控件之媒体控件: Image, MediaElement [源码下载] 重新想象 Windows 8 Store Apps (6) ...

  3. 点击搜索取消UISearchDisplayController的搜索状态

    一般,我们用到UISearchDisplayController的时候,都是须要对一个数据源进行刷选,在UISearchDisplayController自带的tableView中展示出来,然后点击退 ...

  4. 从一开始,说出事java匿名内部类

    java内部类.匿名类原本以为它们的使用已经很滑, 成绩, 就在昨天晚上12指向时钟发生重大事故.事故的严重程度再说吧,那是因为我没有睡一晚睡眠. 那以下先用一段模拟代码来描写叙述下我出现的问题的: ...

  5. lua-TestMore(转)

    http://fperrad.github.io/lua-TestMore/ http://www.softpedia.com/get/Programming/Debuggers-Decompiler ...

  6. c#中的属性

    在C#中我们可以很自由的访问共有字段,但有时我们可能需要某字段只能读或者写,或在改变字段值得时候做一些其他事情,显然这些仅仅依靠字段是无法实现的,于是便有了属性. 1.基本用法 c#中的属性由属性作用 ...

  7. vuejs 相关资料

    官网 http://vuejs.org/ 中文网站 http://cn.vuejs.org/ Vue.js——60分钟快速入门 http://www.cnblogs.com/keepfool/p/56 ...

  8. Android - 分享内容 - 给其他APP发送内容

    创建一个intent时,必须要指定intent将要触发的操作.Android定义了很多操作,包括ACTION_SEND,就象可以猜到的一样,表示intent是把数据从一个activity发送给另一个, ...

  9. 【C语言探索之旅】 第一部分第六课:条件表达式

    内容简介 1.课程大纲 2.第一部分第六课:条件表达式 3.第一部分第七课预告:循环语句 课程大纲 我们的课程分为四大部分,每一个部分结束后都会有练习题,并会公布答案.还会带大家用C语言编写三个游戏. ...

  10. MVC下判断用户登录和授权状态方法

    MVC下判断用户登录和授权状态方法 在我们日常开发的绝大多数系统中,都涉及到管理用户的登录和授权问题.登录功能(Authentication),针对于所有用户都开放:而授权(Authorization ...