I have a main activity. From it, I am calling 2 other sub activities called FacebookLogin and Twitterlogin. I am using the following code in AndroidManufest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.examples.Kikin" android:versionCode="1"
android:versionName="1.0">
<!-- THIS IS THE BEGINNING OF SHARING LINKS FROM THE BROWSER -->
<application android:icon="@drawable/kikinlogo"
android:label="@string/app_name" android:debuggable="true">
<activity android:name=".Kikin" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name=".FacebookLogin" android:label="@string/app_name">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<!-- <data android:mimeType="image/png" /> -->
</intent-filter>
</activity>
<activity android:name=".TwitterLogin" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category andro开发者_开发知识库id:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="yourapp" android:host="twitt"></data>
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" />
Am i doing it right? Should i nest the FacebookLogin and TwitterLogin activities in the main activity? The aforesaid 2 classes are in the package com.examples.. * is the same wherever used.
The labels for your FacebookLogin and TwitterLogin appear to be missing an '@' - change them to android:label="@string/app_name"
There's no such thing as a "subactvity". Just because you call one activity from another doesn't mean it's a "subactivity".
You can't nest activity tags in the manifest and you'd probably get a compile error if you tried.
in manifest you can set only one activity in launcher tag okay android does support multiple launcher activity.
The manifest you posted looked fine.
But regarding your comment about the error message "Have you declared this activity in AndroidManifest.xml?", you need to check carefully the package and class name of the Activity
you are trying to launch, and make sure that it matches the <activity android:name>
you have written in the manifest.
All the info you need should be in the error message.
Don't nest activity declarations, just have them all as elements in your application element:
<manifest ...
<application ...
<activity ...
</activity>
<activity ...
</activity>
<activity ...
</activity>
</application>
</manifest>
The sample you posted here (indenting aside) looks fine.
Maybe you have tested it already but just try declaring your activities with the full path (although you have already declared it in the package tag). So, instead of using
<activity android:name=".TwitterLogin" />
use
<activity android:name="com.examples.Kikin.TwitterLogin" />
Sometimes problems are caused because of that.
I know this is an old thread but Im having the same problem and in my case specifying full package name doesn
t help. Have you already found a solution? I`m really interested in knowing how to avoid this error.
精彩评论