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

  • Home
  • SEARCH
  • 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 8457191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:44:52+00:00 2026-06-10T12:44:52+00:00

Making a SMS App and it is going well so far, but ran into

  • 0

Making a SMS App and it is going well so far, but ran into a problem last night after trying to implement a new activity.

When I click the “Send” Button on my Layout, it sends the SMS, and triggers a Toast notifying me of the Sent SMS. This was working perfectly until I tried to add a onClick attribute to the XML leading to an intent to start the new activity… That’s when this started happening:

Instead of starting up the new activity I created, it sent me to the “New Message” Layout/Activity of the Default “Messaging” app included with the phone. I did not understand this, so took away (unless I’ve missed something over and over) everything that I changed from when it was working.

YET: It is still sending me to that New Message activity when I click this button…

Can someone please tell me where in my code I am telling the application to start that activity? Thank you!

TextActivity.java

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.SmsManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class TextActivity extends Activity {

Button buttonSend;
EditText textPhoneNo;
EditText textSMS;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.text_field);

    buttonSend = (Button) findViewById(R.id.bSendText);
    textPhoneNo = (EditText) findViewById(R.id.etPhoneNumber);
    textSMS = (EditText) findViewById(R.id.etTypeMessage);

    buttonSend.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {

            String phoneNo = textPhoneNo.getText().toString();
            String sms = textSMS.getText().toString();

            Intent sendIntent = new Intent(Intent.ACTION_VIEW);
            sendIntent.putExtra("SMS Body", sms);
            sendIntent.setType("vnd.android-dir/mms-sms");
            startActivity(sendIntent);

            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 failed, please try again later!",
                        Toast.LENGTH_LONG).show();
                e.printStackTrace();
            }
        }
    });
}

// STARTING The Contact Selection Process
private static final int CONTACT_PICKER_RESULT = 1001;

// References the Select Contact Button with onClick="clickHandle"
public void clickHandle(View view) {
    Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
            Contacts.CONTENT_URI);
    startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
}

// Interpreting the results from the Contact_picker
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
        case CONTACT_PICKER_RESULT:
            Cursor cursor = null;
            String phone = "";
            String name = "";
            try {
                Uri result = data.getData();

                // get the contact id from the Uri
                String id = result.getLastPathSegment();

                // query for everything phone
                cursor = getContentResolver().query(Phone.CONTENT_URI,
                        null, Phone.CONTACT_ID + "=?", new String[] { id },
                        null);

                int phoneIdx = cursor.getColumnIndex(Phone.DATA);
                int nameIdx = cursor.getColumnIndex(Phone.DISPLAY_NAME);

                // let's just get the first phone
                if (cursor.moveToFirst()) {
                    phone = cursor.getString(phoneIdx);
                    name = cursor.getString(nameIdx);

                } else {

                }
            } catch (Exception e) {

            } finally {
                if (cursor != null) {
                    cursor.close();
                }
                EditText phoneEntry = (EditText) findViewById(R.id.etPhoneNumber);
                phoneEntry.setText(phone);

                TextView nameEntry = (TextView) findViewById(R.id.tvContactSelected);
                nameEntry.setText(name);

                if (phone.length() == 0) {
                    Toast.makeText(this, "No phone found for contact.",
                            Toast.LENGTH_LONG).show();
                }
            }
            break;
        }

    } else {

    }
}
}

My XML, text_field.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@color/burntorange" >

    <Button
        android:id="@+id/bSelectContact"
        android:layout_width="50dp"
        android:layout_height="45dp"
        android:layout_gravity="center"
        android:layout_margin="4dp"
        android:background="@color/gray"
        android:inputType="phone"
        android:onClick="clickHandle"
        android:text="+"
        android:textColor="@color/white"
        android:textSize="35dp" />

    <TextView
        android:id="@+id/tvContactSelected"
        android:layout_width="290dp"
        android:layout_height="45dp"
        android:layout_gravity="top"
        android:layout_margin="4dp"
        android:background="@color/gray"
        android:gravity="center"
        android:padding="10dp"
        android:text="No Contact Selected"
        android:textSize="20dp" />
</LinearLayout>

<EditText
    android:id="@+id/etPhoneNumber"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="2dp"
    android:gravity="center"
    android:hint="Person&apos;s Phone Number"
    android:padding="10dp" >
</EditText>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/linLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_margin="1dp"
        android:background="@color/burntorange"
        android:descendantFocusability="beforeDescendants"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:gravity="center"
        android:orientation="horizontal"
        android:padding="1dp" >

        <ScrollView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/svEnterMessage"
            android:layout_width="269dp"
            android:layout_height="wrap_content"
            android:paddingBottom="4dp" >

            <EditText
                android:id="@+id/etTypeMessage"
                android:layout_width="260dp"
                android:layout_height="wrap_content"
                android:layout_marginBottom="2dp"
                android:layout_marginRight="4dp"
                android:layout_marginTop="4dp"
                android:background="@drawable/outline"
                android:hint="Type Message Here"
                android:minHeight="35dp"
                android:padding="6dp"
                android:textColor="@color/white"
                android:inputType="textMultiLine" >"
            </EditText>
        </ScrollView>

        <Button
            android:id="@+id/bSendText"
            android:layout_width="75dp"
            android:layout_height="36dp"
            android:layout_marginBottom="2dp"
            android:layout_marginLeft="2dp"
            android:background="@color/gray"
            android:text="Send"
            android:layout_gravity="bottom"
            android:textColor="@color/white" />

    </LinearLayout>

  </RelativeLayout>

</LinearLayout>
  • 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-06-10T12:44:53+00:00Added an answer on June 10, 2026 at 12:44 pm

    Can someone please tell me where in my code I am telling the application to start that activity?

    This looks like it starts the default messaging app:

    Intent sendIntent = new Intent(Intent.ACTION_VIEW);
    sendIntent.putExtra("SMS Body", sms);
    sendIntent.setType("vnd.android-dir/mms-sms");
    startActivity(sendIntent);
    

    If you don’t want to load the default app, what are you trying to do here?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to open just the Phone app from within an application I'm making
I'm making an app that starts a Service that sends SMS message periodically under
Ok, so i am making a Android app that is able to send sms
I am making a app which sends the sms at the scheduled time. The
I'm writing an app for WM that handles incoming SMS events. I tried making
Making a simple map app, plan on adding buttons to mark specific locations But
I am making app for phones, but I wan’t them to be usable on
I have finished making an app. But I have some text in a sharedpreferences
I'm trying to implement sms functionality in Dynamics CRM 2011. I've created a custom
As part of a SMS app I am making, I need to add text

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.