Multiple Activities

Quickly share your Android Code Snippets here...

Multiple Activities

Postby bsbiran » Mon Jun 22, 2009 10:51 am

Hello,

I have three activities.

I need the activityOne to be the default (The one that launches first)

activityTwo and activityThree are launched by activityOne

When I deploy the app to a device I see three apps showing. I assume this is because there are three activities. I only want one app showing and the activityOne launching when its selected.

Any ideas?


<activity android:name=".activityOne"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<activity android:name=".activityTwo" android:label="@string/app_name">
</activity>
<activity android:name=".activityThree" android:label="@string/app_name">
</activity>
bsbiran
Junior Developer
Junior Developer
 
Posts: 16
Joined: Mon Jun 15, 2009 9:56 am

Top

Postby bsbiran » Mon Jun 22, 2009 11:57 am

Just to confirm,

I have a app with three screens (views) should I create an activity for each one?

Thanks
bsbiran
Junior Developer
Junior Developer
 
Posts: 16
Joined: Mon Jun 15, 2009 9:56 am

Postby nmc » Mon Jun 22, 2009 9:11 pm

Yes, you should create an activitiy for every view.

For your manifest.xml:
1. Use the '.xml' Tags when posting
2. There is an "</activity>" Tag missing (".activityOne" isnt closed)
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby bsbiran » Tue Jun 23, 2009 7:15 am

Thanks for the replies. Its working now
bsbiran
Junior Developer
Junior Developer
 
Posts: 16
Joined: Mon Jun 15, 2009 9:56 am

Multiple Activities

Postby SkymanScott » Mon Feb 15, 2010 2:23 am

Noob question, how do you call each of the activities? I've tried listeners and onClicks but end up with a forced close.

For example, I'm trying to get from "inputDate" to "inputTime" activities with a "next" button. I comment out each line and find it "blows up" at the Button statement.

Thanks for your guidance.

public class inputDate extends Activity {

@Override
public void onCreate(Bundle savedValues) {
super.onCreate(savedValues);
setContentView(R.layout.input_date);
Button cmd_submit = (Button) findViewById(R.id.next);
cmd_submit.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
Intent inty = new Intent();
inty.setClass(inputDate.this, inputTime.class);
startActivity(inty);
}
});
}
}
SkymanScott
Once Poster
Once Poster
 
Posts: 1
Joined: Sun Feb 14, 2010 4:52 pm
Location: Florida

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 5 guests