[問題] Android SMS sendDataMessage?
SmsManager 裡頭,有sendDataMessage這方法,指定port發送byte出去,想試試看
程式碼如下:
SmsManager sms = SmsManager.getDefault();
short port = 5000;
sms.sendDataMessage("5554", null, port, "Test".getBytes(), null, null);
請問為什麼接收端一值收不到是發送這邊寫錯了嗎?
接收端AndroidManifest.xml設定指定port
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/>
<data android:scheme="sms" />
<data android:host="localhost"/>
<data android:port="5000"/>
接收端程式
private static final String mACTION = "android.intent.action.DATA_SMS_RECEIVED";
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals(mACTION)){
Log.i("RECEIVE", "GET!");
}
}
請問有經驗的大大是哪裡犯錯了,或是有簡單的指定Port送, 收Data程式可以參考!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.169.68