开发者

How to define several activities from different packages inside the manifest file?

I am having this problem fro couple of days. I have two packages in my project. From my home(inside home package) activity i will call my profile activity (inside proifle package)using a buttons onClickListener method. Heres the code

 private OnClickListener bProfileListener = new OnClickListener() {
    public void onClick(View v) {

        Toast.makeText(getApplicationContext(),
                " You are heading to your Profile page", Toast.LENGTH_SHORT).show();

        Intent intent = new Intent(v.getContext(), Profile.class);          
        startActivityForResult(intent, 0);

    }

}; }

Heres my manifest file. First I defines the package name like this package="com.and.profile".

<application android:label="@string/app_name"
             android:icon="@drawable/icon">
    <activity android:name=".home.Home"
              android:launchMode="singleTask"
              android:stateNotNeeded="true"
              android:label="@string/app_name"
              android:theme="@android:style/Theme.NoTitleBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <catego开发者_Python百科ry android:name="android.intent.category.HOME"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>        
    <activity android:name=".profile.Profile"
    android:label="@string/app_profile"
    android:icon="@drawable/icon"
    android:theme="@android:style/Theme.NoTitleBar">
    </activity>
    <activity android:name=".profile.CustomListViewDB"
    android:label="@string/app_profile"
    android:icon="@drawable/icon">
    </activity>
</application>

When I run this method I am getting this main error....... ERROR/AndroidRuntime(791): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.and.profile.Profile}; have you declared this activity in your AndroidManifest.xml?

Can anybody tell me what to do. Am i missing something? Thanks in adcance.


Try replacing all classes with their fully qualified name.

i.e.: change .profile.Profile to com.and.profile.Profile

That should solve it! After that, check for typos in the class name and other fields!


Have you imported the profile.Profile package (or any other you are using) in the file where you are trying to call them from?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜