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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:31:31+00:00 2026-05-21T19:31:31+00:00

I have a little/big problem in my app in android.I have 2 activity:Activity1 and

  • 0

I have a little/big problem in my app in android.I have 2 activity:Activity1 and Activity2. Activity1 has a TextView and a Button and Activity2 has an EditText and a Button. From Activity1 I go to Acvity2 and I want to send the text from EditText from Activity2 to Activity 1. I get force close because I don’t know the order in code. What should I do? Thanks

Here is my code :


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

public class Activity1 extends Activity {
    TextView txt;
 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

       txt = (TextView) findViewById(R.id.txt);

        Button next=(Button)findViewById(R.id.btn);
        next.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent intent = new Intent(Activity1.this,Activity2.class);
                startActivityForResult(intent, 0);
            }

        });
    }

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

public class Activity2 extends Activity {
    EditText txt2;
 public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main2);

        txt2 = (EditText)findViewById(R.id.txt2);
        final Bundle bundle = new Bundle();
        String x=txt2.getText().toString();
        bundle.putString("param",x);
        Button btn2=(Button)findViewById(R.id.btn2);
        btn2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent intent = new Intent(Activity2.this,Activity1.class);
                intent.putExtra(bundle)
                finish();

            }

        });
          }
}
  • 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-21T19:31:32+00:00Added an answer on May 21, 2026 at 7:31 pm

    One problem with your code is that you don’t have anything handling the result of the second activity. (There’s no onActivityResult in the first activity.)

    The notepad tutorial includes a decent example of calling a second activity and getting a result.

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

Sidebar

Related Questions

i have a little big problem. My problem is the following. I´ve got two
Good day, Stackoverflow! I have a little (big) problem with porting one of my
I have little unusual problem to solve. I need some hint or links to
I have little problem with a replacement of a little part in an url.
I have little problem in regular expressin creation. Expected input: blahblahblah, blahblahblah, 'blahblahblah', blahblahblah,
I'm having a big problem when calling a web service from my WPF application.
i have a little problem here. I am working on a little application wich
I'm moving my websites from a little VPS to a big dedicated server. But
I have a big problem, and I hope you can help me. I'm porting
everybody! I have a little problem with jCarousel, so I really need your help.

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.