Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created 4 edittext that takes different harcoded values. i also have 2 buttons of which one is used to send a message to a particular number. now i want to put the values from these editText to the contents of my message. please help me in acheiving this. here is the code that i have used.

hardcoded edittext values.
Java
gtin=(EditText) findViewById(R.id.editText1);
		gtin.setText(sGtin);
		serial=(EditText) findViewById(R.id.editText2);
		serial.setText(sSerial);
		batch=(EditText) findViewById(R.id.editText3);
		batch.setText(sBatch);
		expiry=(EditText) findViewById(R.id.editText4);
		expiry.setText(sExpiry);


Java
Log.i("Send SMS", "");

         Intent smsIntent = new Intent(Intent.ACTION_VIEW);
         smsIntent.setData(Uri.parse("smsto:"));
         smsIntent.setType("vnd.android-dir/mms-sms");

         smsIntent.putExtra("address"  , new String ("7598149597"));
         smsIntent.putExtra("sms_body"  , "Found illegal medicine");
         smsIntent.putExtra("sSerial", "serial");
         try {
            startActivity(smsIntent);
            finish();
            Log.i("Finished sending SMS...", "");
         } catch (android.content.ActivityNotFoundException ex) {
            Toast.makeText(ScanScreen.this,
            "SMS faild, please try again later.", Toast.LENGTH_SHORT).show();
         }


in smsIntent.putExtra how do i put the values from the edittext?
Posted
Comments
Mohibur Rashid 27-May-15 2:14am    
serial.getText().toString() will give you the string typed in your TextEdit box.
Rahul Ramakrishnan 27-May-15 2:17am    
i tried it..its not working
Mohibur Rashid 27-May-15 4:08am    
What is the error? what problem are you facing? "Its not working" is not good enough
Rahul Ramakrishnan 27-May-15 4:16am    
i get no errors..
the problem is that i want to get all the editText values into the message

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900