最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
android手機短信發(fā)送-創(chuàng)新互聯(lián)

剛學(xué)android不久,最近衛(wèi)衛(wèi)發(fā)給我了一個視頻,是怎樣制作android手機上的×××,一方面我感覺很有意思,另一方可以陪著她一起,今天弄完了,特來總結(jié)一下,雖然說比較簡單吧,但還是有總結(jié)的必要的。

站在用戶的角度思考問題,與客戶深入溝通,找到濟水街道網(wǎng)站設(shè)計與濟水街道網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗,讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗好的作品,建站類型包括:成都做網(wǎng)站、網(wǎng)站設(shè)計、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣、申請域名、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋濟水街道地區(qū)。

×××主要是用于android下的短信發(fā)送的,其主要的界面就是輸入發(fā)送母的人的號碼和要發(fā)的信息的內(nèi)容,主要界面有兩個TextView和兩個EditText還有一個Button(在import android.widget.*),下面是布局文件(layout):

  xmlns:android="http://schemas.android.com/apk/res/android"

  android:layout_width="fill_parent"

  android:layout_height="fill_parent"

 android:orientation="vertical" >

  

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="@string/number"

    />

  

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:id="@+id/number"

    />

  

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:text="@string/content"

    />

  

    android:layout_width="fill_parent"

    android:layout_height="wrap_content"

    android:minLines="3"

    android:id="@+id/context"

    />

  

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:text="@string/button"

    android:id="@+id/button"

   />

以上布局文件使用的string的值需要在value/string.xml進行設(shè)置,主要的代碼如下:

  smsTest

  Settings

  請輸入短信內(nèi)容

  請輸入手機號

  發(fā)送信息

 發(fā)送成功

以上就是布局,可以到AVD中試試是否成功,但是我們要完成這個×××還需要在主程序.java寫上相應(yīng)的處理。

package com.example.smstest;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.telephony.gsm.SmsManager;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.Toast ;

import java.util.ArrayList;//以上是需要的包

@SuppressWarnings( "deprecation" )

public class MainActivity extends Activity {

 private EditText numberText ;//這個變量時用來接受布局中輸入的號碼

 private EditText contentText ;//這個變量時用來接受布局中輸入的信息

 @Override

 protected void onCreate(Bundle savedInstanceState) {//此類程序會從這歌開始在執(zhí)行

 super.onCreate(savedInstanceState);//調(diào)用父類Activity中的onCreate方法

 setContentView(R.layout.activity_main);//執(zhí)行布局文件

 numberText = (EditText) this.findViewById( R.id.number ) ; //接受布局中輸入框中的號碼

 contentText = (EditText) this.findViewById(R.id.context) ;//接受布局中輸入框中的信息

 Button button = (Button) this.findViewById(R.id.button) ;//使用Button

 button.setOnClickListener( new ButtonClick() ) ;//設(shè)置Button響應(yīng)的內(nèi)容

 }

 private final class ButtonClick implements View.OnClickListener

 {

 @Override

 public void onClick( View arg0 ) {

  String number = numberText.getText().toString() ;//接受布局中輸入框中的號碼

  String content = contentText.getText().toString();

  SmsManager manger = SmsManager.getDefault();//建立短信管理對象

  ArrayList texts=manger.divideMessage(content) ;//如果短信過長超過一條短信的大值那么分為多條短信發(fā)送

  for ( String text : texts ) {

  manger.sendTextMessage(number, null, text, null, null) ;//發(fā)送消息(第一個是目的號碼,第三個是消息內(nèi)容)

  }

  Toast.makeText(getApplicationContext(), R.string.success, Toast.LENGTH_LONG ).show() ;

  //使用Toast提示短信發(fā)送成功

 }

 }

 @Override

 public 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;

 }

}

這樣就可以了,可以在兩個模擬器中發(fā)送(漢字會亂碼但手機不會)android手機短信發(fā)送

但是這樣仍然不能再手機中使用,因為手機中的使用的話是要有使用權(quán)限的比如允許其扣除話費,那么獲得權(quán)限就需要修改/smsTest/AndroidManifest.xml中加一個權(quán)限的代碼

  package="com.example.smstest"

  android:versionCode="1"

  android:versionName="1.0" >

  

    android:minSdkVersion="6"

    android:targetSdkVersion="10" />

  

    android:allowBackup="true"

    android:icon="@drawable/ic_launcher"

    android:label="@string/app_name"

    android:theme="@style/AppTheme" >

    

      android:name="com.example.smstest.MainActivity"

      android:label="@string/app_name" >

      

        

        

      

    

  

   

紅體字是加上去的,其余是自動生成的,到此×××OK了。

2014/04/03 14:44

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


新聞名稱:android手機短信發(fā)送-創(chuàng)新互聯(lián)
本文來源:http://fisionsoft.com.cn/article/dpjpcp.html