当前位置: 首页 > news >正文

单产品 网站ppt设计说明

单产品 网站,ppt设计说明,深圳最新政策,手机网站底部代码1、发送短信涉及到权限#xff0c;我们需要把权限加上 2、当我们发送短信时#xff0c;不管发送是否成功#xff0c;接收方是否接收到#xff0c;系统都会发送广播 3、这时我们注册广播去接收一下就可以了 4、布局文件很简单#xff0c;里面就两个EditText和一个button 下… 1、发送短信涉及到权限我们需要把权限加上 2、当我们发送短信时不管发送是否成功接收方是否接收到系统都会发送广播 3、这时我们注册广播去接收一下就可以了 4、布局文件很简单里面就两个EditText和一个button 下面上代码里面有注释: 发送广播接收器:   package com.example.fanlei.cutnotedemo;import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telephony.SmsManager; import android.widget.Toast;/*** 监听短信是否已经发送成功*/ public class MySmsSendReceiver extends BroadcastReceiver {Overridepublic void onReceive(Context context, Intent intent) {if (intent.getAction().equals(SMS_SEND)){switch(getResultCode()){case Activity.RESULT_OK:Toast.makeText(context,发送成功,Toast.LENGTH_SHORT).show();break;case SmsManager.RESULT_ERROR_GENERIC_FAILURE:Toast.makeText(context,发送失败,Toast.LENGTH_SHORT).show();break;case SmsManager.RESULT_ERROR_NO_SERVICE:break;case SmsManager.RESULT_ERROR_NULL_PDU:break;case SmsManager.RESULT_ERROR_RADIO_OFF:break;}}} } 接收方的广播 package com.example.fanlei.cutnotedemo;import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast;/*** 监听对方是否发已经接收到短信*/ public class MySmsDeliverReceiver extends BroadcastReceiver {Overridepublic void onReceive(Context context, Intent intent) {if (intent.getAction().equals(SMS_DELIVER)){switch(getResultCode()){case Activity.RESULT_OK:Toast.makeText(context,对方已接收,Toast.LENGTH_SHORT).show();break;case Activity.RESULT_CANCELED:break;}}} } 主函数 package com.example.fanlei.cutnotedemo;import android.app.PendingIntent; import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.telephony.SmsManager; import android.view.View; import android.widget.EditText; import android.widget.Toast;import java.util.List;public class MainActivity extends ActionBarActivity {private EditText editText1,editText2;private MySmsSendReceiver mySmsSendReceiver; //发送短信的广播private MySmsDeliverReceiver mySmsDeliverReceiver;//对方是否已经接收的广播 Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);mySmsSendReceiver new MySmsSendReceiver();mySmsDeliverReceiver new MySmsDeliverReceiver();editText1 (EditText) findViewById(R.id.editText1);//手机号editText2 (EditText) findViewById(R.id.editText2);//内容//初始化启动意图Intent sendIntent new Intent();sendIntent.setAction(SMS_SEND);Intent deliverIntent new Intent();deliverIntent.setAction(SMS_DELIVER);//满足条件后执行Intentfinal PendingIntent send PendingIntent.getBroadcast(MainActivity.this,0 ,sendIntent,0);final PendingIntent deliver PendingIntent.getBroadcast(MainActivity.this,0,deliverIntent,0);//发送短信按钮findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {Overridepublic void onClick(View v) {String phoneNumber editText1.getText().toString();String content editText2.getText().toString();if (phoneNumber.equals()){Toast.makeText(MainActivity.this,手机号码为空,Toast.LENGTH_SHORT).show();}else {//获得短信的管理者SmsManager sm SmsManager.getDefault();//短信字数限制如果70则需要拆分短信发送if (content.length() 70){ListString contents sm.divideMessage(content);for (String sms : contents){sm.sendTextMessage(phoneNumber,null,sms,send,deliver);//发送短信}}else {sm.sendTextMessage(phoneNumber,null,content,send,deliver);//发送短信}}}});//注册广播registerReceiver(mySmsSendReceiver,new IntentFilter(SMS_SEND));registerReceiver(mySmsDeliverReceiver,new IntentFilter(SMS_DELIVER));} } 布局文件 RelativeLayout xmlns:androidhttp://schemas.android.com/apk/res/androidxmlns:toolshttp://schemas.android.com/toolsandroid:layout_widthmatch_parentandroid:layout_heightmatch_parentandroid:paddingLeftdimen/activity_horizontal_marginandroid:paddingRightdimen/activity_horizontal_marginandroid:paddingTopdimen/activity_vertical_marginandroid:paddingBottomdimen/activity_vertical_margintools:context.MainActivityEditTextandroid:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:idid/editText1android:hint手机号android:inputTypephone/EditTextandroid:idid/editText2android:layout_widthmatch_parentandroid:layout_heightwrap_contentandroid:layout_belowid/editText1android:layout_alignParentLefttrueandroid:layout_alignParentStarttrueandroid:hint内容/Buttonandroid:layout_widthwrap_contentandroid:layout_heightwrap_contentandroid:idid/buttonandroid:layout_centerVerticaltrueandroid:layout_centerHorizontaltrueandroid:text发送短信 //RelativeLayout 小伙伴们可以用10086进行测试 转载于:https://www.cnblogs.com/819158327fan/p/4932788.html
http://www.pierceye.com/news/130329/

相关文章:

  • 网站制作网站建站公司用wordpress
  • 做资讯网站盈利措美网站建设
  • 山东建设工程执业证书查询网站建网是什么
  • 大型服装网站建设wordpress留言板模版
  • 延安做网站沈阳学网站制作学校
  • 网站添加新闻网站免费正能量软件不良
  • asp c 网站开发互动网门户网站建设
  • 图书馆网站结构怎么做国外超酷设计网站
  • 网站开发软件搭配学室内设计去哪好
  • 南通营销网站制作河南省大型项目建设办公室网站
  • 黄山网站建设怎么做seo快速优化技术
  • 百度有做企业网站吗ppt设计主题怎么设置
  • 网页设计与网站开发pdf网站个人建设
  • ip138禁止查询该域名商务网站建设组成包括网站优化
  • 百度做网站续费费用seo分析工具有哪些
  • 威胁网站检测平台建设郑州seo服务
  • 怎么设立网站赚广告费合肥新站区有做网站的吗
  • 管理系统 网站模板网站建立不安全
  • 模板网站的域名是什么意思百度教育智能小程序
  • 哪里有做配音的兼职网站wordpress菜单图标特效
  • 怎样自创广告网站海南网站建设推广公司哪家好
  • 网站开发团队人员网站建设开票属于什么服务
  • 学做网站初入门教程上海网站建设 觉策动力
  • 丰台建站公司做一个企业网站需要哪些技术
  • 黑色网站模板怎么写app程序
  • 常州建设局网站首页网站开发需求文档模板带er图
  • 网站名称是否已被注册简单的个人主页网站制作
  • 太仓网站开发wordpress留言板
  • 大型营销型网站制作装饰画
  • 移动网站和定制网站个体户 做网站