• 简易短信发送器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即可)

  • 相关阅读:
    浅谈Cauchy不等式
    终于结束的起点——CSP-S 2019 第二轮游记
    LOJ 10172 涂抹果酱
    数字表格
    CSP-S 2019 第一轮 游记
    20191011模拟赛
    Luogu 2327 扫雷
    NOIAC 30 candy
    FormData文件上传
    sde表空间无法导入数据和编辑
  • 原文地址:https://www.cnblogs.com/AlexCheng/p/2119994.html
Copyright © 2020-2023  润新知