erfasst wurde Bitte sagen Sie mir, dass, wie ich die gleiche Nachricht löschen kann, die ich auf der OnReceive-Methode erfasst wurde. Ich wünsche mir, dass wenn eine Massage auf onReceive-Methode empfangen wird, es zuerst aus und nach Gebrauch gelöscht wird, aber wie ich nicht weiß, also bitte helfen Sie mir im Fall. Code, den ich benutze auch mit diesem Thread tag.So löschen Sie die gleiche SMS, die auf onReceive Methode
@Override
public void onReceive(Context context,final Intent intents){
if (intents.getAction().equals(ConstantClass.SMS_RECEIVED)) {
new Thread(){
Context context;
Thread Set(Context ctx){
this.context=ctx;
return this;
}
public void run(){
try{
Bundle bundle = intents.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdus.length];
for (int i = 0; i < pdus.length; i++)
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
String msg=null;
String address = null;
for (SmsMessage message : messages) {
msg = message.getMessageBody();
address = message.getOriginatingAddress();
}
dba.Open();
int id = dba.getCordiId(address);
int count = dba.getDeviceCount(ConstantClass.dbName[1]);
if(count<=0){
dba.InsertCurrentCoord(id,id);
}else{
Strsql = new String("UPDATE " + ConstantClass.dbName[1] + " SET " + DataBaseAdapter.Key_ReceiverCoord + " = " +
Integer.toString(id) + " WHERE " + DataBaseAdapter.Key_ID + " = ?");
dba.UpdateQuery(Strsql, Integer.toString(id));
}
dba.Close();
////////////sending to SMSSync class//////////////
MainThread th = new MainThread(sync,msg);
try{
th.thread.join();
}catch(Exception e){
Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
}
if(msg.substring(3, 4).equals("2"))
ConstantClass.isAuditrequestSend = true;
}
/*******after receiving the sms opening the Main Screen.*****************/
Intent intent = new Intent(context,ZigbeeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
abortBroadcast();
/************Now deleting the SMS from the Inbox*********************/
Uri uriSms = Uri.parse("content://sms");
Cursor c = context.getContentResolver().query(uriSms, null,null,null,null);
int trId= c.getInt(0);
int thread_id =c.getInt(1);
context.getContentResolver().delete(Uri.parse("content://sms/conversations/" + thread_id),null,null);
}catch(Exception e){
dlg = new ExceptionDialog(context,"On Sms Receiver",e.getMessage());
dlg.show();
}
}
}.Set(context).start();
}
}
Paste Code mit gut Vertiefung löschen komplette Gewinde für eine bestimmte Anzahl verwendet. Ich habe versucht, es zu formatieren, aber nicht Einzug. –
Warum Sie zuerst die SMS speichern und dann löschen können Sie direkt einschränken, bevor Sie in Ihrem onreciev speichern – vipin