在其他包(主包)中打开 activity B 与 activity A 不同的 package/folder

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

我目前正在为本学期的期末项目开发移动应用程序。我想知道如何从另一个包中的另一个 activity 中打开一个包中的 activity。

示例:

com.example.package1
中的 FirstActivity Package2 中的 SecondActivity
Package2 在 com.example.package1

里面

我想在 FirstActivity 中单击按钮时打开 SecondActivity。

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

请在第一个 activity

中导入第二个 activity class 试试这个方法

首先在 onClickListener 内部 activity

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

像这样在您的清单文件中添加 activity:

<activity
        android:name=". Your folder name where Second Activity is present then . 
        (Second Activity Name)"/>

在 Java 文件中是这样的:

Intent intent = new Intent(FirstActivit.this,Second activity.class);
start activity(intent)