简易短信发送器iSMS

image

这是一个由哥开发的简单的不能再简单的短信发送器。

附上源码:

 
 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.     android:orientation="vertical"
  4.     android:layout_width="fill_parent"
  5.     android:layout_height="fill_parent"
  6.     >
  7.  
  8.       <TextView
  9.         android:text="@string/moble"
  10.         android:layout_width="fill_parent"
  11.         android:layout_height="wrap_content"
  12.         />
  13.     <EditText
  14.         android:id="@+id/mobile"
  15.         android:layout_width="fill_parent"
  16.         android:layout_height="wrap_content" />
  17.         <TextView
  18.         android:text="@string/content"
  19.         android:layout_width="fill_parent"
  20.         android:layout_height="wrap_content"
  21.         />
  22.     <EditText
  23.         android:id="@+id/content"
  24.         android:layout_width="fill_parent"
  25.         android:layout_height="wrap_content"
  26.         android:minLines="5" />
  27.     <Button
  28.         android:id="@+id/send"
  29.         android:text="@string/send"
  30.         android:layout_width="fill_parent"
  31.         android:layout_height="wrap_content"
  32.             ></Button>
  33. </LinearLayout>
 
 
  1. package gphone.cc.iSMS; 
  2.  
  3. import android.app.Activity; 
  4. import android.os.Bundle; 
  5. import android.telephony.SmsManager; 
  6. import android.view.View; 
  7. import android.widget.Button; 
  8. import android.widget.EditText; 
  9. import android.widget.Toast; 
  10.  
  11. import java.util.ArrayList; 
  12.  
  13. public class iSMSActivity extends Activity 
  14.     EditText mobile=null; 
  15.     EditText content=null; 
  16.     Button sent=null; 
  17.     /** Called when the activity is first created. */
  18.     @Override
  19.     public void onCreate(Bundle savedInstanceState) 
  20.     { 
  21.         super.onCreate(savedInstanceState); 
  22.         setContentView(R.layout.main); 
  23.  
  24.              
  25.  
  26.  
  27.         sent=(Button)this.findViewById(R.id.send); 
  28.         sent.setOnClickListener(new Button.OnClickListener(){ 
  29.             public void onClick(View view) { 
  30.                 mobile=(EditText)findViewById(R.id.mobile); 
  31.                 String mobileStr=mobile.getText().toString(); 
  32.                 content=(EditText)findViewById(R.id.content); 
  33.                 String contentStr=content.getText().toString(); 
  34.  
  35.                 SmsManager smsManager=SmsManager.getDefault(); 
  36.  
  37.                 if(contentStr.length()>70){ 
  38.                     ArrayList<String> contents=smsManager.divideMessage(contentStr); 
  39.                     for(String sms :contents){ 
  40.                          smsManager.sendTextMessage(mobileStr,null,contentStr,null,null); 
  41.                     } 
  42.                 } 
  43.                 else{ 
  44.                     smsManager.sendTextMessage(mobileStr,null,contentStr,null,null); 
  45.  
  46.                 } 
  47.                 Toast.makeText(iSMSActivity.this,R.string.msg,Toast.LENGTH_LONG).show(); 
  48.  
  49.             } 
  50.         }); 
  51.  
  52.  
  53.     } 

androidminifast.xml

 
 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3.       package="gphone.cc.iSMS"
  4.       android:versionCode="2"
  5.       android:versionName="1.1">
  6.     <application android:label="@string/app_name" android:icon="@drawable/icon">
  7.         <activity android:name="iSMSActivity"
  8.                   android:label="@string/app_name">
  9.             <intent-filter>
  10.                 <action android:name="android.intent.action.MAIN" />
  11.                 <category android:name="android.intent.category.LAUNCHER" />
  12.             </intent-filter>
  13.         </activity>
  14.            </application>
  15.     <uses-sdk android:minSdkVersion="3"/>
  16.     <uses-permission android:name="android.permission.SEND_SMS"/>
  17.      
  18.  
  19. </manifest> 

string.xml

 
 
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <resources>
  3.     <string name="app_name">iSMS</string>
  4.     <string name="moble">请电话输入号码</string>
  5.     <string name="content">请输入短信内容</string>
  6.     <string name="send">发送短信</string>
  7.     <string name="msg">短信已发送</string>
  8. </resources>

下载地址:iSMS (rar改为apk即可)

转载于:https://www.cnblogs.com/AlexCheng/archive/2011/07/12/2119994.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值