Start activity from another package - Issue

2019-08-23 04:38发布

问题:

I downloaded library project from github and imported it into my app project.The problem is that i want to start activity from this library in my main app class.I tried many ways and one of them was:


Intent intent = new Intent();

intent.setComponent(new ComponentName( "com.tehedligmail.restorancafeler.RestaurantActivity , "com.cunoraz.pickImages.MainActivity"));"

startActivity(intent);


This is my log:

08-29 04:40:13.937: E/AndroidRuntime(11778):

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.tehedligmail.restorancafeler.RestaurantActivity/com.cunoraz.pickImages.MainActivity};

have you declared this activity in your AndroidManifest.xml?

_---------------------------------------------------------------------------

i tried this but manifest can't show the package and activity class:

 <activity android:name="com.luminous.pick.MainActivity">  
            <intent-filter>  
                <action android:name="com.luminous.pick.MainActivity" />  
                <category android:name="android.intent.category.DEFAULT" />  
            </intent-filter>  
        </activity> 

As i understand from log i should define the class that i want to launch in my manifest,but i couldn't write this,even autocomplete of manifest didn't show this class's name.

Thanks in advance.

For more information This is image shows library and main project of my app

回答1:

As the document, I think the package name is problem. Can you try this?

intent.setComponent(new ComponentName( "com.cunoraz.pickImages", "com.cunoraz.pickImages.MainActivity"));"

And no need to declare this activity in AndroidManifest.xml