open activity B in different package/folder from activity A in other package (main package)


I’m currently working on a mobile app for our final project this semester. I want to know how to open an activity in a package from another activity from a different package.


FirstActivity in com.example.package1
SecondActivity in Package2
Package2 is inside in the com.example.package1

I want to open SecondActivity when a button is clicked in FirstActivity.

The underlined class is the 2nd Activity and the highlighted one is the 1st activity.

Here’s the code from the MM_Play.class (first activity)

Here’s the code in the AndroidManifest.xml


Please try this way by import second activity class in first activity

Inside onClickListener in First activity

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);

Answered By – gpuser

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published