I have the following scenario.
I have 2 packages in my application.
com.example.package1;
org.otherexample.package2;
I declare in manifest like this:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.package1"
android:versionCode="1"
android:versionName="1.0" >
<activity android:name=".ActivityfromPackage1"/>
<activity android:name="org.otherexample.package2.ActivityFromPackage2"/>
</manifest>
This being the manifest, now I want to Call From ActivityFromPackage1 ActivityFromPackage2
I’ve done like this:
import org.otherexample.package2.ActivityFromPackage2
..........
Intent intent = new Intent(this,ActivityFromPackage2.class);
startActivity(intent);
I receive following error:
Unable to start Activity com.example.package1/org.otherexample.package2.ActivityFromPackage2:
JavaLang nullpointer exception
How to call the Activity?
Thanks a lot.
I suspect that something outside of what you’ve posted here is the root of your problem. I just made an example project to test it out.
Here are my two activity declarations in manifest:
Here is the relavent bit from MainActivity:
Note that in my second Activity I had to import R from the main package:
But after doing that everything compiles and runs correctly.
Also note in my Log file it shows:
Which like yours shows both of the different package names even though AnotherActivity is only in
com.example.anotherpackage