Android error “unable to find explicit activity cl

2019-01-11 10:28发布

I have an android project with several packages. The structure of the packages in this case is com.WAPP.SetLocation is the package that contains the activity I want to run.

In my manifest, com.WAPP is considered the base package:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.WAPP"
      android:versionCode="1"
      android:versionName="1.0">

My activities are declared in my manifest as:

<activity android:name=".mainScreenActivity"></activity>
<activity android:name=".SetLocation.setLocationActivity"></activity>

The mainScreen activity displays fine, since it is inside the com.WAPP package. But when I try to run the setLocationActivity, I get the unable to find explicit class error. Here is how I have the intent parameters:

Intent i = new Intent();
            i.setClassName("com.WAPP.SetLocation",
                           "com.WAPP.SetLocation.setLocationActivity");
            startActivity(i);

7条回答
叼着烟拽天下
2楼-- · 2019-01-11 11:22

Do it by this way:

Intent intent = new Intent();
intent.setComponent(
        new ComponentName("com.WAPP", "com.WAPP.SetLocation.setLocationActivity"));
startActivity(i);
查看更多
登录 后发表回答