0
I have two activities put in extremely different packages as shown in the codes 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 receiving the Activitynotfoundexception exception even though Activity is set on 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 fix this error? This is happening because of the packages?
Note that in the error message in the part { com.main.package/Additional.package.Otheractivity } it says that it is looking for the additional package within the main package. He has to be informed ( I don’t know how ) that this is not the case.
– Reginaldo Rigo
Just put it on the manifest
<ativity android:name=".OtherActivity" />
. You are prefixing a package in which Otheractivity does not exist (or the package itself does not exist)– Lennoard Silva