Start activity from another package - Issue

这一生的挚爱 提交于 2019-12-24 20:13:27

问题


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



来源:https://stackoverflow.com/questions/45924397/start-activity-from-another-package-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!