0
アンドロイドで特定の番号のSMSメッセージをアプリケーション作成ディレクトリにリダイレクトすることは可能ですか?また、メッセージは受信ボックスに表示されません。 ように共有設定をクリアSMSをアンドロイドアプリケーションディレクトリにリダイレクト
アンドロイドで特定の番号のSMSメッセージをアプリケーション作成ディレクトリにリダイレクトすることは可能ですか?また、メッセージは受信ボックスに表示されません。 ように共有設定をクリアSMSをアンドロイドアプリケーションディレクトリにリダイレクト
アプリケーション
public void onReceive(Context context, Intent intent) {
// ---get the SMS message passed in---
Bundle bundle = intent.getExtras();
SmsMessage[] msgs = null;
String msgString = "", senderinfo = "";
String timeStamp1;
if (bundle != null) {
// ---retrieve the SMS message received---
Object[] pdus = (Object[]) bundle.get("pdus");
msgs = new SmsMessage[pdus.length];
for (int i = 0; i < msgs.length; i++) {
msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
senderinfo += msgs[i].getOriginatingAddress();
msgString += msgs[i].getMessageBody().toString();
}
// ---display the new SMS message---
Toast.makeText(context, senderinfo, Toast.LENGTH_SHORT).show();
}
if(senderinfo == "Your Specific phone Numbers"){
SharedPreferences settingsActivity = getSharedPreferences("Message", Activity.MODE_PRIVATE);
SharedPreferences.Editor prefEditor = settingsActivity.edit();
prefEditor.putString(Messages, msg);
prefEditor.commit();
abortBroadcast();
}
にMSGをrecivingため、幅広いキャストレシーバを実装する助けてくださいとメッセージを取得した後、アプリケーション
SharedPreferences settingsActivity = getSharedPreferences("Message", Activity.MODE_PRIVATE);
settingsActivity.getString("Messages",msg);
にデータを取得します新しいメッセージを保存することができます
SharedPreferences.Editor editor = settingsActivity.edit();
editor.remove("Messages");
editor.clear();
editor.commit();
あなたのfas t replyこのコードを試してみてください – vipin
これも受信トレイに保存されています – vipin
abortBroadcast()を使用していますので、受信トレイに保存しないでください。 – user1203673