はいそこの方法ですが、残念ながらのKiの展開以来、それ以上は簡単ではありません。バージョン> Jelly Beanで作業するには、アプリケーションを既定のSMSアプリケーションとして実行する必要があります。つまり、変更およびabortBroadcast()を実行する必要があります。 4.3以下の場合は、放送受信機を作成し、次のような何かを:
public void onReceive(Context context, Intent intent) {
// Get the SMS map from Intent
Bundle extras = intent.getExtras();
String messages = "";
if (extras != null) {
// Get received SMS array
Object[] smsExtra = (Object[]) extras.get(SMS_EXTRA_NAME);
// Get ContentResolver object for pushing encrypted SMS to the incoming folder
ContentResolver contentResolver = context.getContentResolver();
for (int i = 0; i < smsExtra.length; ++i) {
SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
String body = sms.getMessageBody().toString();
String address = sms.getOriginatingAddress();
// Here is where you modify the body of the message!
messages += "SMS from " + address + " :\n";
messages += body + "\n";
putSmsToDatabase(contentResolver, sms);
}
}
}
private void putSmsToDatabase(ContentResolver contentResolver, SmsMessage sms) {
// Create SMS row
ContentValues values = new ContentValues();
values.put(ADDRESS, sms.getOriginatingAddress());
values.put(DATE, sms.getTimestampMillis());
values.put(READ, MESSAGE_IS_NOT_READ);
values.put(STATUS, sms.getStatus());
values.put(TYPE, MESSAGE_TYPE_INBOX);
values.put(SEEN, MESSAGE_IS_NOT_SEEN);
try {
values.put(BODY, sms.getMessageBody()); // May need sms.getMessageBody.toString()
}
catch (Exception e) {
e.printStackTrace();
}
// Push row into the SMS table
contentResolver.insert(Uri.parse(SMS_URI), values);
}
この情報は、here
から入手したほとんど忘れてしまった...定数を..
public static final String SMS_EXTRA_NAME = "pdus";
public static final String SMS_URI = "content://sms";
public static final String ADDRESS = "address";
public static final String PERSON = "person";
public static final String DATE = "date";
public static final String READ = "read";
public static final String STATUS = "status";
public static final String TYPE = "type";
public static final String BODY = "body";
public static final String SEEN = "seen";
public static final int MESSAGE_TYPE_INBOX = 1;
public static final int MESSAGE_TYPE_SENT = 2;
public static final int MESSAGE_IS_NOT_READ = 0;
public static final int MESSAGE_IS_READ = 1;
public static final int MESSAGE_IS_NOT_SEEN = 0;
public static final int MESSAGE_IS_SEEN = 1;
「そこにISN Androidでそれを行う方法、良さに感謝します。ただし、SMSブロードキャストを傍受し、必要に応じて通知を抑制することができます。 – 323go
はい、androdiネイティブコードを使用する方法があります。ここにAndeはあなたが始めるのに役立つリンクです:http://stackoverflow.com/questions/11435354/receiving-sms-on-android-app –
多分Husamはあなたのための解決策を持っています。あなたはあなたがしたいことがはっきりしていません。編集する - >保存する - >表示しますか?だから唯一のsmsはあなたの編集されたものになります。または、編集したSMSメッセージをトーストとして表示したいのですが、実際のSMSメッセージを編集する必要はありませんか? –