Android发送短信
来源:互联网 发布:网络信息监测 编辑:程序博客网 时间:2024/06/05 02:07
源码:package com.example.sms;import android.os.Bundle;import android.app.Activity;import android.app.PendingIntent;import android.content.Intent;import android.telephony.SmsManager;import android.view.Menu;import android.view.View;import android.widget.Button;public class MainActivity extends Activity {PendingIntent paIntent;SmsManager smsManager;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);paIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0); smsManager = SmsManager.getDefault();Button Btn1 = (Button)findViewById(R.id.button1);//获取按钮资源 Btn1.setOnClickListener(new Button.OnClickListener(){//创建监听 public void onClick(View v) { smsManager.sendTextMessage("15211362665", null, "这条短信是自动发送的", paIntent, null); } }); }@Overridepublic boolean onCreateOptionsMenu(Menu menu) {// Inflate the menu; this adds items to the action bar if it is present.getMenuInflater().inflate(R.menu.main, menu);return true;}}Manifest文件<?xmlversion="1.0"encoding="utf-8"?><manifestxmlns:android="http://schemas.android.com/apk/res/android" package="com.example.sms" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18"/> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name="com.example.sms.MainActivity" android:label="@string/app_name"> <intent-filter> <actionandroid:name="android.intent.action.MAIN"/> <categoryandroid:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> <uses-permissionandroid:name="android.permission.SEND_SMS"></uses-permission> </manifest>
0 0
- android 中发送短信
- android中发送短信
- android发送短信
- Android 发送短信
- Android自动发送短信
- Android发送短信
- android 发送短信sms
- android 发送短信
- android发送短信
- Android短信发送器
- android 之短信发送
- Android自动发送短信
- android短信发送
- Android发送短信
- android 发送短信问题
- android 短信发送程序
- Android发送短信
- Android短信发送程序
- 兰州烧饼
- EXTJS 组件开发(完整例子)
- Tomcat7新特性及兼容性考虑
- curl_easy_setopt函数介绍
- ceph一些基础概念的简介
- Android发送短信
- Dungeon Game
- http_load基准测试(整站式测试)
- Linux内核调优之Sysctl研究
- 关于Fragment使用的一些见解
- 为啥富人越富穷人越穷
- JNI使用流程及简单例子
- 《深入理解Python》读书笔记Ⅲ
- No 'Access-Control-Allow-Origin' header is present on the requested resource. 报错解决。