- 浏览: 28010 次
- 性别:
- 来自: 北京
最新评论
-
xiaojianhx:
Environment 是哪个包里面的?我开发4.0,用不了这 ...
Android 检测SD卡应用 -
qianlei541:
不错不错不错
android软键盘enter键的替换与事件监听 -
ihopethatwell:
到处都是转载的,楼主,你这个图片这个调用能贴上?
android yuv摄像 -
mikite:
mark,看看
Android中的动画研究 -
anyang763:
多谢lz分享,学习了!
android系统调用
模拟android短信发送器的实现
AndroidManifest.xml清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ljq.sms"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.SEND_SMS"/>
</manifest>
main.xml布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:layout_width="115dip"
android:layout_height="wrap_content"
android:text="请输入手机号"
android:id="@+id/mobilelabel" />
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/mobilelabel"
android:text="5556"
android:id="@+id/mobile" />
</RelativeLayout>
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="请输入短信内容" />
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minLines="3"
android:text="I am a teacher!"
android:id="@+id/content" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="发送"
android:id="@+id/button" />
</LinearLayout>
MainActivity类
package com.ljq.sms;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends Activity {
private EditText mobileText=null;
private EditText contentText=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mobileText=(EditText)findViewById(R.id.mobile);
contentText=(EditText)findViewById(R.id.content);
Button button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
String mobile=mobileText.getText().toString();
String content=contentText.getText().toString();
//取得android系统中默认的短信管理器
SmsManager manager=SmsManager.getDefault();
//如果短信内容过长时,则对短信内容进行拆分
ArrayList<String> texts=manager.divideMessage(content);
for(String text:texts){
//第一个参数:对方手机号码
//第二个参数:短信中心号码,一般设置为空
//第三个参数:短信内容
//第四个参数:sentIntent判断短信是否发送成功,如果你没有SIM卡,或者网络中断,则可以通过这个intent来判断。
//注意强调的是“发送”的动作是否成功。那么至于对于对方是否收到,另当别论
//第五个参数:当短信发送到收件人时,会收到这个deliveryIntent。即强调了“发送”后的结果
//就是说是在"短信发送成功"和"对方收到此短信"才会激活sentIntent和deliveryIntent这两个Intent。这也相当于是延迟执行了Intent
manager.sendTextMessage(mobile, null, text, null, null);
}
//Toast.makeText(getApplicationContext(), "发送成功", Toast.LENGTH_LONG).show();
Toast.makeText(MainActivity.this, "发送成功", Toast.LENGTH_LONG).show();
}
});
}
}
调用系统自带短信发送:
public void SendSMS(){
Uri smsToUri = Uri.parse("smsto:123456");
Intent sendIntent = new Intent(Intent.ACTION_VIEW, smsToUri);
String str = getString(R.string.smsString);
sendIntent.putExtra("sms_body",str);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
// finish();
}
发表评论
-
android 的 Linkify
2011-12-29 09:03 1170Linkify是一个辅助类,通过RegEx样式匹配,自动地在T ... -
Android教程之AndroidManifest.xml文件详介绍及解析
2011-12-21 16:58 0一、关于AndroidManifest.xml Android ... -
obj文件应用
2011-12-20 09:27 0OBJ文件格式(转http://www.ategpu.com/ ... -
Android 应用程序多Activity跳转之后退出整个程序
2011-12-13 11:48 867http://txlong-onz.iteye.com/blo ... -
Android 检测SD卡应用
2011-12-13 10:21 7040if (Environment.getExternalStor ... -
android yuv摄像
2011-12-13 09:26 2873http://eyehere.net/2011/android ... -
Android拍摄视频流的格式转换(YUV --- RGB)
2011-12-13 08:56 1818Android允许用户实时捕获摄像头的视频流,这在利用摄像头的 ... -
android软键盘enter键的替换与事件监听
2011-12-12 09:03 3480软件盘的界面替换只有一个属性android:imeOption ... -
android listView
2011-12-06 09:11 0一、 1 listview中在设置了背景之后,会发生listv ... -
Android 即时通讯 XMPP
2011-12-05 09:47 0http://www.cnblogs.com/charley_ ... -
搭建XMPP协议,实现自主推送消息到手机
2011-12-05 09:46 0http://www.devdiv.com/article-2 ... -
xmpp协议实现消息推送
2011-12-05 09:43 0http://www.cnblogs.com/luxiaofe ... -
Android推送方式比较
2011-12-05 09:32 0http://blog.csdn.net/xyz_lmn/ar ... -
Android教程之AndroidManifest.xml文件详介绍及解析
2011-12-02 09:25 0Android教程之AndroidManifest.xml文 ... -
Android用GSon处理Json数据
2011-12-02 08:57 4http://www.cnblogs.com/VinC/arc ... -
Android访问WCF服务---服务端开发
2011-12-02 08:45 0Android访问WCF服务(上篇)-服务端开发 本章目的: ... -
高效率下载图片——防止内存溢出
2011-12-01 12:06 0在应用中经常需要下载很多的图片,因此,写好图片下载部分的代码非 ... -
ScrollListener
2011-12-01 12:00 0new OnScrollListener() { bo ... -
Android虚拟机(DVM)内存分配——内存溢出问题
2011-12-01 11:57 0大家都知道Android的上层应用是基于 Dalvik Vir ... -
bitmap溢出处理
2011-12-01 11:40 0当从SD卡中获取图片时,如果图片太大,加载会出现溢出异常。因此 ...
相关推荐
Qt android 发短信,查看短信
本例为使用android发送短信的例子 为本人习作 可以在android2.3之上运行
Android发送短信程序,需要的可以下下来看看。
今天写了一个发短信的小例子和大家分享一下,自己测试过可以成功发送。
Android初学小程序,简单的发送短信程序,已在Android4.2手机上实验过。
NULL 博文链接:https://ouyangfeng521.iteye.com/blog/1094857
android发送短信息程序,还有界面切换,短信拦截 源代码
该程序是在android运行的发短信程序,代码简单易懂
android发短信源码,利用android的api发动短信,发送成功后有吐司提示
android发送短信代码,主要用于短信验证等,如获取验证码~~~
android 短信发送 可直接部署使用
这是做的一个简单的短信发送,这也是最简单的一个了,这是第一版的短信发送
Android发短信
android 定时发送短信(新) android 手机定时发送短信程序,支持2.2以上版本。功能:即时发送短信,定时发送短信,取消定时发送,拨号,自动搜索联系人,此次修补上次出现的bug。
unity调用Android Api实现短信发送和震动功能
利用android开发短信发送程序,实现两个模拟器之间发送信息,文章详见 http://blog.csdn.net/cndrip/article/details/7170830
Android: 短信发送实例. SmsManager.
通过Android实现的发短信源码,服务监听Android短信,可提取短信端号码
android发送短信代码,主要用于短信验证等,如获取验证码.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。