Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5843769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:12:01+00:00 2026-05-22T12:12:01+00:00

In my app, there is list containing phone contacts. When user clicks on a

  • 0

In my app, there is list containing phone contacts. When user clicks on a contact, he can choose from a menu to send an sms to the contact (or email, or other things).

Cursor people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
                    while(people.moveToNext()) {
                      int nameFieldColumnIndex = people.getColumnIndex(PhoneLookup.DISPLAY_NAME);
                      String contact = people.getString(nameFieldColumnIndex);
                      int numberFieldColumnIndex = people.getColumnIndex(PhoneLookup.NUMBER);
                      String number = people.getString(numberFieldColumnIndex);
                        if (contact.equals(myArr2_cs[item]))
                            {
                            Intent int_sms = new Intent(Intent.ACTION_SEND);
                            int_sms.setType("text/plain");
                            int_sms.putExtra(Intent.EXTRA_EMAIL  , new String[]{number});
                            int_sms.putExtra(Intent.EXTRA_SUBJECT, "");
                            int_sms.putExtra(Intent.EXTRA_TEXT, "");
                            try {
                               startActivity(Intent.createChooser(int_sms, "Sending SMS.."));
                            } catch (android.content.ActivityNotFoundException ex) {
                               Toast.makeText(MainActivity.this, "No installed sms clients found", Toast.LENGTH_SHORT).show();
                            }

The intent part is designed for sending e-mail – it shows user a list to choose from clients, which is what i want.
You see there are two variables for the contact name and the phone number.
User clicks on a name of the list then clicks on send sms, a pop up list appears to choose from sms, email, bluetooth etc. I choose go sms or any other installed sms app from the pop up list, the client appears with the fields (to, text) empty. I want the number to appear in the sms box of the sms form. So if user clicks on “Tom Jones” and then clicks on “send sms”, Tom Jones’number should already be filled in the client. My code does not do this.

I also tried sending sms with these lines, but they resulted in force close:

SmsManager sm = SmsManager.getDefault();
String number2 = "6508570720";//this should the number variable
sm.sendTextMessage(number2, null, "Test SMS Message", null, null);

OR

Intent sendIntent= new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", "smsBody");
sendIntent.putExtra("address", number);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:12:02+00:00Added an answer on May 22, 2026 at 12:12 pm

    I have noticed that, using this code randomly crashes my app (Don’t know the reason for sure)

    sm.sendTextMessage(number2, null, "Test SMS Message", null, null);
    

    Instead, if I do this, it never crashes:

    PendingIntent sent = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
    PendingIntent delivered = PendingIntent.getBroadcast(context, 0, new Intent(), 0);
    sm.sendTextMessage(number2, null, "Test SMS Message", sent, delivered);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a good Django app out there that can take a list of
In my app there is a button, user just click it then the latest
When hosting WPF user controls within a WinForms MDI app there is a drawing
My app consolidates data from other DBs for reporting purposes. We can't link the
I am trying to send information to a server from an android phone. When
Are there any list of PhoneGap apps in the app store that I could
In my app there is requirement that..I have 6 buttons in a nib, when
In my app there is the view says googleBtn. If i press on it
I'm coding an app that works much like Apple's Weather.app: There's a UIPageControl at
I'm trying to embed Google's directions into an iphone app There doesn't seem to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.