Two Main Activities in Androidmanifest.Xml

Two main activities in AndroidManifest.xml

The LAUNCHER intent filter is what determines what shows up in the app drawer/launcher. That is why you get two icons shown up.

However, you also set the DEFAULT intent filter, which sets the default Activity for the whole package. Since you set it twice, you get the problem of precedence of the first/latest registered. When you remove the DEFAULT filter, you will be able to start whatever you click on in the launcher.

In short, remove the following line from both Activities:

<category android:name="android.intent.category.DEFAULT" /> 

How to declare multiple activities in Manifest.xml on Android Eclipse

It is telling you that in your layout main3, you must have a TabHost named android.R.id.tabhost

In onCreate() you are inflating main3:

setContentView(R.layout.main3);

Open up main3.xml and make sure your layout looks something like this:

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp" >

<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>

</TabHost>

Note the TabHost's name and the name of the TabWidget.

See here for a full example.

Activity Declaration in AndroidManifest.xml

You have two activities in your package, but have only declared one in manifest.

Declare the other Activity class:

Add this to your manifest:

<activity
android:name="com.example.stockquote.StockInfoActivity"
android:label="@string/app_name" />

how to declare two packages with their activities in android manifest file?

It seems you have made a few mistakes in the XML:

<manifest package="com.tabwidget">
<application>

1) BELOW: starting the names by "." means that
you are implicitely extending the package prefix defined in the package
attribute of the manifest XML tag.
For example, if your package is "com.tabwidget", defining".MyActivity"
will be interpreted as "com.tabwidget.MyActivity"
By removing the first ".", you use an explicit notation instead:
whatever your package is, "com.tabwidget.MyActivity" is interpreted
as "com.tabwidget.MyActivity"
<activity android:name=".com.tabwidget.Tab"></activity>
<activity android:name=".com.tabwidget.TabHostProvider"></activity>
<activity android:name=".com.tabwidget.TabView"></activity>
</application>
</manifest>

2) BELOW: a manifest file should only contain one manifest XML tag:
<manifest package="com.kpbird.tabbarcontrol">
<application>

3) BELOW: same mistake as 1)
<activity android:name=".com.kpbird.tabbarcontrol.TabbarView"></activity>
</application>
</manifest>

What follows should work. It fixes these 3 mistakes:

<manifest package="com.kpbird.tabbarcontrol">
<application>
<activity android:name="com.tabwidget.Tab"></activity>
<activity android:name="com.tabwidget.TabHostProvider"></activity>
<activity android:name="com.tabwidget.TabView"></activity>
<activity android:name=".TabbarView"></activity>
</application>
</manifest>


Related Topics



Leave a reply



Submit