0

I am a newbie in android development, so plz try to explain complex steps.

I want to know what codes to write for the following process:-

Activity1 takes number input via EditText then perform some actions on it, lets say it multiply it with 2, then send this new number to another activity Activity2 where it is displayed.

Mainly i want to know how to display the new number in an activity.

Thnx in Advance.

Mohit
  • 1,045
  • 4
  • 18
  • 45
  • 2
    Go through Intents in Android. You really had to google or search this question on SO before posting here. – Rashmi.B May 28 '12 at 09:42
  • 1
    Try to search in `Google` or `Stackoverflow` first. After ask as question while you didn't get any solution. – Praveenkumar May 28 '12 at 09:43
  • See this.. http://stackoverflow.com/questions/10069609/pass-data-from-one-activity-to-another-but-go-to-the-other-activity-later – Ron May 28 '12 at 09:44

4 Answers4

4

You need to pass the data from one activity to another activity..

Main.java

Intent it=new Intent(Main.this,Expense.class);
it.putExtra("a", food);
startActivity(it);

Second.java

Bundle b=getIntent().getExtras();
if(b!=null)
{
    String fud=b.getString("a");
}
textview.setText(fud);
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
code_finder
  • 1,370
  • 2
  • 21
  • 39
2

The answer in the following question shows how data can be passed between activities.Before that read about intents carefully.

How do I pass data between Activities in Android application?

Community
  • 1
  • 1
Mukund Samant
  • 1,079
  • 7
  • 12
1

Refer this example

add this in activity 1

Intent myIntent = new Intent(Activity1.this, Activity2.class);
myIntent.putExtra("UserId",UserId);
myIntent.putExtra("UserName",UserName);
startActivity(myIntent);

add this in activity 2

Intent intent = getIntent();
UserId=intent.getStringExtra("UserId");
UserName=intent.getStringExtra("UserName");
Praveenkumar
  • 24,084
  • 23
  • 95
  • 173
KMI
  • 496
  • 4
  • 24
0

Intents in Android is what you are looking for

Rashmi.B
  • 1,787
  • 2
  • 18
  • 34