Android Error "unable To Find Explicit Activity Class"
Solution 1:
The first parameter is application package not the package where the activity is.
You can invoke the Activity like this.
Intenti=newIntent();
i.setClassName("com.WAPP",
"com.WAPP.SetLocation.setLocationActivity");
startActivity(i);
It is preferred as SYLARRR suggested to have Android automatically figure that out for you. Hence the call as..
startActivity(newIntent(this, setLocationActivity.class));
It's recommended per java standards to have the package name all lower-cased and the class name as CamelCased.
Solution 2:
If the new activity not in the same packet with MainActivity(you call from here?), try declare on manifest
<activityandroid:name="com.WAPP.SetLocation.setLocationActivity"></activity>
and in the caller
Intent intent = newIntent(this, setLocationActivity.class);
startActivity(intent);
Hope this helps!
Solution 3:
In additional to the above answers make sure that your activities are declared inside application in manifest
<applicationandroid:allowBackup="true"android:label="@string/app_name"android:supportsRtl="true"><activityandroid:name=".mainScreenActivity"></activity><activityandroid:name=".SetLocation.setLocationActivity"></activity></application>
Solution 4:
If i'm not mistaken, the i.setClassName("com.WAPP.SetLocation","com.WAPP.SetLocation.setLocationActivity");
should be i.setClassName(getBaseContext(),"setLocationActivity");
Reference
Also try this syntax:
startActivity(newIntent(MyActivity.this, setLocationActivity.class));
and try removing the starting dot from:
<activityandroid:name=".SetLocation.setLocationActivity"></activity>
Solution 5:
Do it by this way:
Intentintent=newIntent();
intent.setComponent(
newComponentName("com.WAPP", "com.WAPP.SetLocation.setLocationActivity"));
startActivity(i);
Post a Comment for "Android Error "unable To Find Explicit Activity Class""