I have two activities but in extremely different packages as shown below:
MainActivity
package com.main.package;
import ...;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent i = new Intent(getApplicationContext() ,OtherActivity.class);
startActivity(i);
}
}
OtherActivity
package additional.package;
import ...;
public class OtherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent i = getIntent();
if (i != null) {
String errorMessage = i.getStringExtra("error");
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("A error was found!!");
dialog.setMessage(errorMessage);
dialog.create().show();
}
}
}
AndroidManifest
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@style/Fullscreen" >
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<ativity
android:name="additional.package.OtherActivity" />
But I'm always getting the ActivityNotFoundException exception even though the activity is set to AndroidManifest.
Error
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.main.package/com.main.package.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.main.package/additional.package.OtherActivity}; have you declared this activity in your AndroidManifest.xml?
How can I resolve this error? Is this happening because of the packages?