This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to switch from one activity to another activity

 
sohaib rahman
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks!

I have come with a new problem. The problem is that there is a Welcome Screen which has a start button. I want to switch from WelcomeScreen Activity to another Activity on the click of the Start button. I anyone has an example then please reply me.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good morning,
use this on the clickListener function to open a new activity

//Open new activity
Intent myIntent = new Intent();
myIntent.setClassName("com.yourDomain.appName", "com.yourDomain.appName.activityName");
startActivity(myIntent);

you can pass parameters to the new activity if you use

myIntent.putExtra();
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's what Intents are for. The "Activating Components" section of the "Application Fundamentals" page in the SDK Dev Guide talks about that.
 
Espen Myklevoll
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is only a personal preference, but I feel that this keeps things nice and clean

In your other activity, add this method:



Then you can call this activity from your WelcomeScreen activity, or any other class simply by running this:

 
Mayu Mayooresan
Ranch Hand
Posts: 37
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
calling new activiy and sending data with Intent is easy

check out this Small Tutorial
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic