導航:首頁 > 源碼編譯 > 安卓獲取簡訊內容源碼

安卓獲取簡訊內容源碼

發布時間:2023-09-04 02:20:07

android 開發 一個通過服務端內容自動發送簡訊到指定號碼

調用系統的發送簡訊界面,只需向系統發送一個Intent,並附帶相關參數就可以了,下面以一個仿差demo說明。

類似下圖的界面


activity_main.xml


[html] view plain

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

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<Button

android:id="@+id/btn_send"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_alignParentRight="true"

android:layout_marginRight="@dimen/padding_small"

android:gravity="center"

android:paddingLeft="@dimen/padding_small"

android:paddingRight="@dimen/padding_small"

android:text="@string/btn_send" />

<EditText

android:id="@+id/edit_phone_number"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignBottom="@id/btn_send"

android:layout_marginLeft="@dimen/padding_small"友悔

android:layout_marginRight="@dimen/padding_small"

android:layout_toLeftOf="@id/btn_send"

android:hint="@string/edittext_hint"

android:inputType="phone"

android:paddingLeft="@dimen/padding_small" />

</RelativeLayout>


然後在MainActivity中編寫相應的java代碼就可以了,操作很簡單,在EditText中輸入號碼,然後點擊Send,就跳到系統發備告皮送簡訊界面,並且接收人一欄里填入號碼。相關的代碼如下:


獲取控制項,響應Button的點擊事件:


[java] view plain

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

mEditText = (EditText) findViewById(R.id.edit_phone_number);

mButton = (Button) findViewById(R.id.btn_send);

mButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String phoneNumber = mEditText.getText().toString();

if (!TextUtils.isEmpty(phoneNumber)) {

sendSmsWithNumber(MainActivity.this, phoneNumber);

}

}

});

}


向指定號碼發送簡訊:

[java] view plain

/**

* 調用系統界面,給指定的號碼發送簡訊

*

* @param context

* @param number

*/

public void sendSmsWithNumber(Context context, String number) {

Intent sendIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("smsto:" + number));

context.startActivity(sendIntent);

}

這樣點擊Send後,就會跳轉到系統簡訊界面了,並且接收人一欄里就是剛才你填寫的號碼。


同理,要想調用系統發送簡訊界面後附加簡訊內容和以上是類似的,只需在Intent中附帶相關的參數就可以了。

[java] view plain

/**

* 調用系統界面,給指定的號碼發送簡訊,並附帶簡訊內容

*

* @param context

* @param number

* @param body

*/

public void sendSmsWithBody(Context context, String number, String body) {

Intent sendIntent = new Intent(Intent.ACTION_SENDTO);

sendIntent.setData(Uri.parse("smsto:" + number));

sendIntent.putExtra("sms_body", body);

context.startActivity(sendIntent);

}

❷ 安卓開發如何獲取簡訊驗證碼

利用後端雲可以輕松完成簡訊驗證,開發時代碼可以參照相應後端雲的開發文檔。

如Bmob後端雲,開發文檔地址網頁鏈接

❸ 如何獲取android手機有未讀簡訊

Cursor csr = context.getContentResolver().query(Calls.CONTENT_URI, new String[] {Calls.NUMBER, Calls.TYPE, Calls.NEW}, null, null, Calls.DEFAULT_SORT_ORDER);這個可以查詢未接來電但我用eclipse並沒有Sms.CONTENT_URI,所以無法查詢未讀簡訊的條數哪位大俠請指點一下如何獲取未讀簡訊的條數?我是用eclipse開發,沒用源代碼

❹ Android關於簡訊的源代碼在packages/apps/Mms ,可是packages/apps/Mms這個在哪裡

你是要看手機在系統根目錄下的存有簡訊信息的代碼或文字嗎,首先要有root許可權,然後要有能打開系統根目錄的文件管理器,推薦re管理器(界面簡單內存小),文件路徑:根目錄/data/data/ com.android.providers.telephony/databases/mmssms.db

mmssms.db選擇資料庫查看,點開word或word_content可以看到簡訊內容,我截圖給你看,滿意請採納,謝謝!

閱讀全文

與安卓獲取簡訊內容源碼相關的資料

熱點內容
pop3伺服器怎麼裝 瀏覽:138
cpp編譯解決命名沖突問題 瀏覽:507
單片機的晶振頻率 瀏覽:481
翻樣軟體加密鎖問題 瀏覽:204
電腦怎麼設置dhcp伺服器地址 瀏覽:591
十天突破雅思寫作劍8pdf 瀏覽:354
如何判定伺服器硬碟燒了 瀏覽:243
數值逼近pdf 瀏覽:706
程序員跪鍵盤 瀏覽:3
江蘇銀行app換設備電話按哪個鍵 瀏覽:235
圖片無損壓縮怎麼辦 瀏覽:6
如何確認伺服器的光口網卡 瀏覽:243
nb1111y壓縮機性能數據 瀏覽:549
下一代編譯器 瀏覽:131
用什麼app可以查產品批號 瀏覽:437
python自動補齊 瀏覽:906
蘋果wifi安卓怎麼連接不上 瀏覽:934
為什麼有的app只能用蘋果支付 瀏覽:176
手游雲頂文件夾 瀏覽:939
msvc和mingw都是編譯器嗎 瀏覽:428