sms - Insert predefined message into existing conversation (Android) -


is there way can insert predefined message existing conversation in inbox app built on android platform?

with code able retrieve last sent , received messages.

public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); textview tv = new textview(this);  uri urisms = uri.parse("content://sms/"); cursor cur = getcontentresolver().query(urisms, null, null, null, null); cur.movetonext();  string body = cur.getstring(cur.getcolumnindex("body"));    string add = cur.getstring(cur.getcolumnindex("address")); string time = cur.getstring(cur.getcolumnindex("date")); string protocol = cur.getstring(cur.getcolumnindex("protocol"));         string contactname = ""; uri personuri = uri.withappendedpath( contactscontract.phonelookup.content_filter_uri, uri.encode(add));   cursor c = getcontentresolver().query(personuri, new string[] { phonelookup.display_name }, null, null, null );   if( c.movetofirst() ) {                int nameindex = c.getcolumnindex(phonelookup.display_name);                contactname = c.getstring(nameindex); } c.close(); cur.close();  string out = ""; date d = new date(long.valueof(time));   if (protocol == null)     out = "sending to: "+ contactname + " <"+add +">\ndate: "+d +"\nbody: "+body+"\n\n"; else      out = "received from: "+ contactname + " <"+add +">\ndate: "+d +"\nbody: "+body+"\n\n";  tv.settext(out); setcontentview(tv);  } 

is there way can incorporate broadcast receiver (smsreceiver.java)? there way can trigger event when new message received can insert predefined message conversation related newest text message in inbox.

while i'm @ it. there way accurately retrive native phone number without asking user enter manually?

solved using following code in receiver.

contentvalues values = new contentvalues();  values.put("address", "0123456789");  values.put("body", "message goes here");   context.getcontentresolver().insert(uri.parse("content://sms/"), values); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -