Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid-passing string from one activity to another activity is not working,
    primarykey
    data
    text
    <p>I want to pass one string variable from one activity to another activity,but is not working for me,i want to send the string from Main activity to sendsms activity.The sending string should be set in sms message part.</p> <p>Main activity.java</p> <pre><code>@Override public void onClick(View v) { StringBuffer sb = new StringBuffer(); // Retrive Data from list for (Application bean : items) { if (bean.isSelected()) { sb.append(Html.fromHtml(bean.getContent())); sb.append(","); } } showAlertView(sb.toString().trim()); } @SuppressWarnings("deprecation") private void showAlertView(String str) { AlertDialog alert = new AlertDialog.Builder(this).create(); final String strContactList = str.substring(0, str.length() - 1); if (TextUtils.isEmpty(str)) { alert.setTitle("Not Selected"); alert.setMessage("No One is Seleceted!!!"); } else { // Remove , end of the name alert.setTitle("Selected"); alert.setMessage(strContactList); } alert.setButton("sms", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //sendSMS(); /*Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", strContactList); sendIntent.setType("vnd.android-dir/mms-sms"); startActivity(sendIntent);*/ Intent intent1=new Intent(MainActivity.this,SendSMSActivity.class); intent1.putExtra("firstkeyName", strContactList); startActivity(intent1); } }); </code></pre> <p>from main activity to send an string to sendsmsactivity.java</p> <p>sendsmsactivity.java</p> <pre><code>public class SendSMSActivity extends Activity { Button buttonSend; EditText textPhoneNo; EditText textSMS; String sms; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); buttonSend = (Button) findViewById(R.id.buttonSend); textPhoneNo = (EditText) findViewById(R.id.editTextPhoneNo); textSMS = (EditText) findViewById(R.id.editTextSMS); Bundle extras = getIntent().getExtras(); if(extras !=null) { sms = extras.getString("firstkeyName"); } buttonSend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String phoneNo = textPhoneNo.getText().toString(); try { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo, null, sms, null, null); Toast.makeText(getApplicationContext(), "SMS Sent!", Toast.LENGTH_LONG).show(); } catch (Exception e) { Toast.makeText(getApplicationContext(), "SMS faild, please try again later!", Toast.LENGTH_LONG).show(); e.printStackTrace(); } } }); } } </code></pre> <p>In the sendsmsactivity, i want to get the string from main activity and it has to set as sms body of the send sms activity.i want to do like that,but right now my code is not working ,its not getting the string from main to sendsmsactivity.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload