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 8093931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:37:47+00:00 2026-06-05T20:37:47+00:00

to send a message in my application in android i have used the following

  • 0

to send a message in my application in android i have used the following code.

package wishme.code;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class Activity2 extends Activity{

    public void onCreate(Bundle savedInstancestate) {
        super.onCreate(savedInstancestate);
        setContentView(R.layout.main2);
        Button previous=(Button) findViewById(R.id.button_prev);
        Button send=(Button) findViewById(R.id.button_send);
        EditText ph_no=(EditText) findViewById(R.id.edit_phone);
        EditText msg=(EditText) findViewById(R.id.edit_msg);

    }
    public void prevclickhandler(View view)
    {
        switch(view.getId())
        {
        case R.id.button_prev:
        Intent intent=new Intent();
        setResult(RESULT_OK,intent);
        finish();
        break;
        case R.id.button_send:
            **String ph_no= ph_no.getText().tostring();** 
    }}
}

But the line highlighted gives error that is
the method getText is undefined for the type string
how can i resolve this.

  • 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-05T20:37:48+00:00Added an answer on June 5, 2026 at 8:37 pm

    Your variables are defined in different scopes. The ph_no EditText is defined in onCreate and not available in your click handler. The ph_no you are actually calling getText() on is the String you are defining.

    Instead, you can define the EditText inside your Activity as a instance variable and rename your String so the variable names don’t collide.

    Another approach is to just call findViewById when you need access to the EditText, like so:

    String ph_no = ((EditText) findViewById(R.id.edit_phone)).getText().toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the package android.telephony.SmsManager to send an SMS message from within my application,
I have used share inbuilt dialog of android. Which fetch all application which is
i am developing an android application wherein i have to send a frame in
I have created an application for Android that has an activity that has a
In manifest in application tag I have: <receiver android:name=.MyC2dmReceiver android:permission=com.google.android.c2dm.permission.SEND> <!-- Receive the actual
Hi I want to send message from one application (which will be installed on
I am attempting to send a json message from a custom application to a
I want to send an SMS message from my facebook application so that the
I am developing a simple application which has to send an SMS message from
We have a client application that needs to send messages to a server for

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.