Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get an incoming SMS' phone number?
    primarykey
    data
    text
    <p>How do I get an incoming SMS' phone number?</p> <p>I wrote <code>BroadcastReciever</code> as in <a href="https://stackoverflow.com/questions/5692659/how-would-i-track-incoming-sms-in-android">this link</a>, but I don't get any output. Also the Toast message in that <code>BroadcastReciever</code> does not get displayed.</p> <p>Here is another <code>sms.java</code> file for which I used that <code>BroadcastReciever</code>.</p> <pre><code>public class SMS extends Activity { /** Called when the activity is first created. */ Button btn; EditText edt1; EditText edt2; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); btn=(Button) findViewById(R.id.btn1); edt1=(EditText) findViewById(R.id.edt1); edt2=(EditText) findViewById(R.id.edt2); btn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub String phone=edt1.getText().toString(); String message=edt2.getText().toString(); if (phone.length()&gt;0 &amp;&amp; message.length()&gt;0) sendSMS(phone, message); else Toast.makeText(getApplicationContext(), "Enter the phone_no &amp; message.", Toast.LENGTH_SHORT).show(); } }); } private void sendSMS(String phoneNumber, String message) { Intent i1 = new Intent(this, SMS.class); PendingIntent pi = PendingIntent.getActivity(this, 0, i1 , 0); SmsManager SMS1 = SmsManager.getDefault(); SMS1.sendTextMessage(phoneNumber, null, message, pi, null); } } </code></pre>
    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