Hi I worked on application,in which the message are retrieve from web service
. The websevice
gives response like (contactnumber + "##" + message + "##" + Username)
.
I want store message like
inbox in the phone. Please any one give me some idea.
Asked
Active
Viewed 151 times
-2
-
This may help http://stackoverflow.com/questions/642076/how-to-save-sms-to-inbox-in-android – Antrromet May 04 '12 at 10:12
2 Answers
0
Well you will have 3 steps : 1) contact webservice using an http request (you will find plenty tutorials on how to do this) 2) parse the response (in your case you split the string but it's not very robust ...) 3) store the message where you want (please be more precise on where you want to store it)

Estragon
- 1,462
- 11
- 12
0
STEP 1: Get web message using HttpGet as:
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet();
request.setURI(new URI("YOUR_WEB_SERVCE"));
HttpResponse response = client.execute(request);
in = new BufferedReader
(new InputStreamReader(response.getEntity().getContent()));
StringBuffer sb = new StringBuffer("");
String line = "";
String NL = System.getProperty("line.separator");
while ((line = in.readLine()) != null) {
sb.append(line + NL);
}
in.close();
String webmesg = sb.toString();
STEP 2:
use TelephonyManager for getting your own mobile number as:
TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String strmobinum= tm.getLine1Number();
AndroidManifest.xml:
<uses-permission android:name= "android.permission.READ_PHONE_STATE"/>
STEP 3:
USE SmsManager for sending sms :
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(strmobinum, null, webmesg, null, null);
AndroidManifest.xml:
<uses-permission android:name="android.permission.SEND_SMS"/>

ρяσѕρєя K
- 132,198
- 53
- 198
- 213