Note that there are some explanatory texts on larger screens.

plurals
  1. POControl back button functionality
    primarykey
    data
    text
    <p>From the given <code>ListView</code> in picture, I select the contact to send sms and move to another activity (second picture). And from this sms <code>Activity</code> picture. When I press back hardware button available on phone, I should move where I want. I don't want a default <code>Activity</code> to be displayed. How can I do this?</p> <p><img src="https://i.stack.imgur.com/YEnnQ.png" alt=""> <img src="https://i.stack.imgur.com/dL5QV.png" alt=""></p> <pre><code>public class SendSms extends Activity{ ListView listView; List&lt;RowItems&gt; rowItems; CustomListViewAdapter adapter; String toNumbers = ""; String separator; int i=0,j,count=0,count1; String a[]=new String[5]; String number,val2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.new4); listView = (ListView) findViewById(R.id.list); rowItems = new ArrayList&lt;RowItems&gt;(); val2=getIntent().getStringExtra("name"); ContentResolver cr = getContentResolver(); Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null); if (cur.getCount() &gt; 0) { while (cur.moveToNext()) { String rawContactId = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); Cursor c = getContentResolver().query( ContactsContract.CommonDataKinds.Phone.CONTENT_URI, new String[] { ContactsContract.CommonDataKinds.Phone.NUMBER, // ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.PHOTO_ID }, ContactsContract.Data.RAW_CONTACT_ID + "=?", new String[] { rawContactId }, null); if (c != null) { if (c.moveToFirst()) { String number = c.getString(0); //int type = c.getInt(1); String name = c.getString(1); int photoId = c.getInt(2); Bitmap bitmap = queryContactImage(photoId); RowItems p=new RowItems(bitmap, number, name); rowItems.add(p); } adapter = new CustomListViewAdapter(this, R.layout.new5, rowItems); listView.setAdapter(adapter); c.close(); } } } } private Bitmap queryContactImage(int imageDataRow) { Cursor c = getContentResolver().query(ContactsContract.Data.CONTENT_URI, new String[] { ContactsContract.CommonDataKinds.Photo.PHOTO }, ContactsContract.Data._ID + "=?", new String[] { Integer.toString(imageDataRow) }, null); byte[] imageBytes = null; if (c != null) { if (c.moveToFirst()) { imageBytes = c.getBlob(0); } c.close(); } if (imageBytes != null) { return BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); } else { return null; } } public void showResult(View v) { // String result = ""; String result1=""; for (RowItems p : adapter.getBox()) { if (p.chck){ // result += "\n" + p.getTitle(); result1 +="\n" +p.getDesc(); a[i]=p.getTitle(); i++; count++; } count1=count; } Toast.makeText(this, result1+"\n", Toast.LENGTH_LONG).show(); } public void send(View v) throws IOException { int value=a.length-count1; for(j=0;j&lt;a.length-value;j++){ if(android.os.Build.MANUFACTURER.equalsIgnoreCase("Samsung")){ separator = ","; } else separator = ";"; number = a[j]; toNumbers= toNumbers +number +separator; } toNumbers = toNumbers.substring(0, toNumbers.length()); Uri sendSmsTo = Uri.parse("smsto:" + toNumbers); String smsValue = "help iam in danger..i am presently at \n"+val2; if(val2==null){ Toast.makeText(SendSms.this, "wait.....", Toast.LENGTH_LONG).show(); } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType("vnd.android-dir/mms-sms"); intent.putExtra("sms_body", smsValue); intent.setData(sendSmsTo); startActivity(intent); } </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.
 

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