新建乙個android專案sns。
<
resources
>
<
string
>
sns傳送簡訊
string
>
<
string
name="hello"
>hello world, mainactivity!
string
>
<
string
name="number"
>輸入手機號
string
>
<
string
name="content"
>請輸入簡訊內容
string
>
<
string
name="button"
>傳送
string
>
<
string
name="success"
>傳送完成
string
>
resources
>
xmlversion="1.0"
encoding="utf-8"
?>
<
linearlayout
xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<
textview
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/number"
/>
<
edittext
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/number"
/>
<
textview
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/content"
/>
<
edittext
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:minlines="3"
android:id="@+id/content"
/>
<
button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"
android:id="@+id/button"
/>
linearlayout
>
public
classmainactivityextendsactivity
private
final
classbuttonclcklistenerimplementsview.onclicklistener
toast.maketext(mainactivity.this, r.string.success
, toast.length_long
).show();}}
傳送成功的三種通知
1. 狀態列通知
2. 對話方塊通知
3. 吐西(toast)(彈出發送成功,一秒自動消失)
傳送簡訊要設定許可權,我們在sdk在docs→index.html
這裡可以看到所有的許可權搜尋send sms可以看到發簡訊的許可權
可以找到
然後可以在manifest申請許可權(manifest節點下)
<
uses-permission
android:name="android.permission.broadcast_sms"
/>
給另外一台模擬器傳送簡訊。
傳送成功的toast效果
Android學習 收發簡訊
使用android api類庫可以自己實現收發簡訊的功能 資訊的傳送,對mms應用程式來講主要是在資訊資料庫中建立並維護一條資訊記錄,真正的傳送過程交由底層 frameworks層 函式來處理 雖然在android系統中已經存在傳送簡訊的應用,但是如果我們在開發其他應用時需要整合傳送簡訊功能,則很方...
Flutter學習 之 Android構建發布
android構建發布中的各種天坑,一次性填完。標籤,這是應用的名稱。uses permission 如果您的應用程式 不需要internet訪問,請刪除android.permission.internet許可權。標準模板包含此標記是為了啟用flutter工具和正在執行的應用程式之間的通訊。檢視構...
筆記 Android 2 簡訊傳送器
簡訊傳送器總結 api總結 boolean textutils.isempty string str 判斷乙個字串是否為空 smsmanager smsmanager.getdefault 建立乙個smsmanager物件 arraylistdevidemessage string text 如果一...