短信发送成功音效时我取消发送,怎么知道有没有成功

您的举报已经提交成功,我们将尽快处理,谢谢!
拦截的信息应该是就没有被手机接收,当然是不能看到的。 所谓拦截,就是遇到被设定为垃圾信息号码所发来的短信时,手机拒绝接收油该信息
是短信中心的号码错了,就是在换模式的时候,自动改了,我知道2个方法,最简单的就是大10086,然后和他说,短信中心的号码错了,麻烦发到我的手机,第二个办法就是 ...
大家还关注
(window.slotbydup=window.slotbydup || []).push({
id: '2081942',
container: s,
size: '1000,60',
display: 'inlay-fix'您的举报已经提交成功,我们将尽快处理,谢谢!
四个0,不是其他
说是发送成功,但不一定就发送过去了,可能是你的标题或者内容有很敏感的词眼,被服务器截了
大家还关注
(window.slotbydup=window.slotbydup || []).push({
id: '2081942',
container: s,
size: '1000,60',
display: 'inlay-fix'Android--判断发送短信后的状态/发送成功Or发送失败_Linux编程_Linux公社-Linux系统门户网站
你好,游客
Android--判断发送短信后的状态/发送成功Or发送失败
来源:Linux社区&
作者:dlutbrucezhang
相信用过诺基亚手机的朋友可能会记得,在短信发送之后,手机会显示发送手机的状态,同样也提供了相应的功能,而且实现这个功能的方法也很简单。
首先,我们需要在程序中注册两个权限:
1.接收短信的权限
2.发送短信的权限
& &uses-permission android:name="android.permission.SEND_SMS"&&/uses-permission&& &uses-permission android:name="android.permission.RECEIVE_SMS"&&/uses-permission&
之后,我们需要开启两个模拟器测试程序的功能,下面是实现的截图,首先看第一张截图,是一个模拟器接收到另一个模拟器发送来的短信显示在通知栏里:
我们会看到这个模拟器的端口号叫做5554,这个就相当于手机号,我们发送短信只要把这个号码当做是手机号使用即可,下面这张截图是主程序的实现截图,点击发送按钮,短信被发出,同时,如果成功,系统会发送广播信息。
截图如下:
下面给出程序的实现代码:
public class EX06_14 extends Activity{& /* 建立两个mServiceReceiver对象,作为类成员变量 */& private mServiceReceiver mReceiver01, mReceiver02;& private Button mButton1;& private TextView mTextView01;& private EditText mEditText1, mEditText2;& & /* 自定义ACTION常数,作为广播的Intent Filter识别常数 */& private static String SMS_SEND_ACTIOIN = "SMS_SEND_ACTIOIN";& private static String SMS_DELIVERED_ACTION = "SMS_DELIVERED_ACTION";& & & /** Called when the activity is first created. */& @Override& public void onCreate(Bundle savedInstanceState)& {& & super.onCreate(savedInstanceState);& & setContentView(R.layout.main);& & & & mTextView01 = (TextView)findViewById(R.id.myTextView1);& & & & /* 电话号码 */& & mEditText1 = (EditText) findViewById(R.id.myEditText1);& & & & /* 短信内容 */& & mEditText2 = (EditText) findViewById(R.id.myEditText2);& & & & mButton1 = (Button) findViewById(R.id.myButton1);& & & & //mEditText1.setText("+");& & /* 设定预设为5556表示第二个模拟器的Port */& & mEditText1.setText("5556");& & mEditText2.setText("Hello DavidLanz!");& & & & /* 发送SMS短信按钮事件处理 */& & mButton1.setOnClickListener(new Button.OnClickListener()& & {& & & @Override& & & public void onClick(View arg0)& & & {& & & & // TODO Auto-generated method stub& & & & & & & & /* 欲发送的电话号码 */& & & & String strDestAddress = mEditText1.getText().toString();& & & & & & & & /* 欲发送的短信内容 */& & & & String strMessage = mEditText2.getText().toString();& & & & & & & & /* 建立SmsManager对象 */& & & & SmsManager smsManager = SmsManager.getDefault();& & & & & & & & // TODO Auto-generated method stub& & & & try& & & & {& & & & & /* 建立自定义Action常数的Intent(给PendingIntent参数之用) */& & & & & Intent itSend = new Intent(SMS_SEND_ACTIOIN);& & & & & Intent itDeliver = new Intent(SMS_DELIVERED_ACTION);& & & & & & & & & & /* sentIntent参数为传送后接受的广播信息PendingIntent */& & & & & PendingIntent mSendPI = PendingIntent.getBroadcast(getApplicationContext(), 0, itSend, 0);& & & & & & & & & & /* deliveryIntent参数为送达后接受的广播信息PendingIntent */& & & & & PendingIntent mDeliverPI = PendingIntent.getBroadcast(getApplicationContext(), 0, itDeliver, 0);& & & & & & & & & & /* 发送SMS短信,注意倒数的两个PendingIntent参数 */& & & & & smsManager.sendTextMessage(strDestAddress, null, strMessage, mSendPI, mDeliverPI);& & & & & mTextView01.setText(R.string.str_sms_sending);& & & & }& & & & catch(Exception e)& & & & {& & & & & mTextView01.setText(e.toString());& & & & & e.printStackTrace();& & & & }& & & }& & });& }& & /* 自定义mServiceReceiver重写BroadcastReceiver监听短信状态信息 */& public class mServiceReceiver extends BroadcastReceiver& {& & @Override& & public void onReceive(Context context, Intent intent)& & {& & & // TODO Auto-generated method stub& & & & & & //mTextView01.setText(intent.getAction().toString());& & & if (intent.getAction().equals(SMS_SEND_ACTIOIN))& & & {& & & & try& & & & {& & & & & /* android.content.BroadcastReceiver.getResultCode()方法 */& & & & & //Retrieve the current result code, as set by the previous receiver.& & & & & switch(getResultCode())& & & & & {& & & & & & case Activity.RESULT_OK:& & & & & & & /* 发送短信成功 */& & & & & & & //mTextView01.setText(R.string.str_sms_sent_success);& & & & & & & mMakeTextToast& & & & & & & (& & & & & & & & getResources().getText(R.string.str_sms_sent_success).toString(),& & & & & & & & true& & & & & & & );& & & & & & && & & & & & case SmsManager.RESULT_ERROR_GENERIC_FAILURE:& & & & & & & /* 发送短信失败 */& & & & & & & //mTextView01.setText(R.string.str_sms_sent_failed);& & & & & & & mMakeTextToast& & & & & & & (& & & & & & & & getResources().getText(R.string.str_sms_sent_failed).toString(),& & & & & & & & true& & & & & & & );& & & & & & && & & & & & case SmsManager.RESULT_ERROR_RADIO_OFF:& & & & & & && & & & & & case SmsManager.RESULT_ERROR_NULL_PDU:& & & & & & && & & & & }& & & & & & & & }& & & & catch(Exception e)& & & & {& & & & & mTextView01.setText(e.toString());& & & & & e.getStackTrace();& & & & }& & & }& & & else if(intent.getAction().equals(SMS_DELIVERED_ACTION))& & & {& & & & try& & & & {& & & & & /* android.content.BroadcastReceiver.getResultCode()方法 */& & & & & switch(getResultCode())& & & & & {& & & & & & case Activity.RESULT_OK:& & & & & & & /* 短信 */& & & & & & & //mTextView01.setText(R.string.str_sms_sent_success);& & & & & & & mMakeTextToast& & & & & & & (& & & & & & & & getResources().getText(R.string.str_sms_rec_success).toString(),& & & & & & & & true& & & & & & & );& & & & & & && & & & & & case SmsManager.RESULT_ERROR_GENERIC_FAILURE:& & & & & & & /* 短信未送达 */& & & & & & & //mTextView01.setText(R.string.str_sms_sent_failed);& & & & & & & mMakeTextToast& & & & & & & (& & & & & & & & getResources().getText(R.string.str_sms_rec_failed).toString(),& & & & & & & & true& & & & & & & );& & & & & & && & & & & & case SmsManager.RESULT_ERROR_RADIO_OFF:& & & & & & && & & & & & case SmsManager.RESULT_ERROR_NULL_PDU:& & & & & & && & & & & }& & & & & & & & }& & & & catch(Exception e)& & & & {& & & & & mTextView01.setText(e.toString());& & & & & e.getStackTrace();& & & & }& & & }& & & & & }& }& & public void mMakeTextToast(String str, boolean isLong)& {& & if(isLong==true)& & {& & & Toast.makeText(EX06_14.this, str, Toast.LENGTH_LONG).show();& & }& & else& & {& & & Toast.makeText(EX06_14.this, str, Toast.LENGTH_SHORT).show();& & }& }& //这是重载Activity中的函数& @Override& protected void onResume()& {& & // TODO Auto-generated method stub& & & & /* 自定义IntentFilter为SENT_SMS_ACTIOIN Receiver */& & IntentFilter mFilter01;& & mFilter01 = new IntentFilter(SMS_SEND_ACTIOIN);& & mReceiver01 = new mServiceReceiver();& & registerReceiver(mReceiver01, mFilter01);& & & & /* 自定义IntentFilter为DELIVERED_SMS_ACTION Receiver */& & mFilter01 = new IntentFilter(SMS_DELIVERED_ACTION);& & mReceiver02 = new mServiceReceiver();& & registerReceiver(mReceiver02, mFilter01);& & & & super.onResume();& }& & @Override& protected void onPause()& {& & // TODO Auto-generated method stub& & & & /* 取消注册自定义Receiver */& & unregisterReceiver(mReceiver01);& & unregisterReceiver(mReceiver02);& & & & super.onPause();& }}
更多Android相关信息见 专题页面
相关资讯 & & &
& (02/09/:35)
& (02/05/:14)
& (02/05/:11)
& (02/05/:10)
& (02/05/:01)
& (02/05/:39)
图片资讯 & & &
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款我把对方电话拉黑了,在拉黑期间不知道对方有没有给我打电话发信息什么的,但是我偶尔取消拉黑后不久对方_百度知道
我把对方电话拉黑了,在拉黑期间不知道对方有没有给我打电话发信息什么的,但是我偶尔取消拉黑后不久对方
但是我偶尔取消拉黑后不久对方就会发来信息?求各位意见,这是怎么回事,在拉黑期间不知道对方有没有给我打电话发信息什么的?或是没打过电话 我拉黑然后取消拉黑他电话会有显示吗!&#128591我把对方电话拉黑了,难道我这边拉黑和取消拉黑对方都知道吗
拉黑了,别人打电话会说您拨打的电话正在通话中,没拉黑就打得进来
其他类似问题
为您推荐:
打电话的相关知识
其他2条回答
这个不会有显示的,一般是他打的次数比较多,你恰好取消他有恰好打进来了
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁消费者最喜爱的网站主办:中国电子视像行业协会
售后服务(9:00-21:00):020-
问题未解决
[问题已过期]
我怎么才能知道手机发出去的短信对方是否收到了?
我来回答:
参考资料:若您的回答是从其它地方引用的,请说明出处。
(第一次回答可获2分,答案被采纳还可获得悬赏分和额外20分奖励)
商城特价促销
相关问题       }

我要回帖

更多关于 ios短信发送成功声音 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信