bogdy9912 bogdy9912 - 2 days ago 4
Android Question

Intent- swich XML

I have a problem, my app does't work when i use Intent to swich XML file's. That is in main:

public void Hit()
{
if ( (alergator1Y - alergatorHigh <= alergator3Y && alergator1X == alergator3X) ||
(alergator1Y - alergatorHigh <= alergator5Y && alergator1X == alergator5X))
{
crono.stop();
timer.cancel();
Intent intent = new Intent(getApplicationContext(), Result.class);
startActivity(intent);
}

}


and that in my Result class:

public class Result extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_results);

}

public void tryAgain(View view) {
startActivity(new Intent(getApplicationContext(), Main.class));
}


}

and logcat said:

12-01 02:13:07.644 5233-5233/com.example.bogadan.runbabyrun E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.bogadan.runbabyrun, PID: 5233
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.bogadan.runbabyrun/com.example.bogadan.runbabyrun.Result}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1805)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1523)
at android.app.Activity.startActivityForResult(Activity.java:4224)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:48)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:75)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:856)
at android.app.Activity.startActivity(Activity.java:4507)
at android.app.Activity.startActivity(Activity.java:4475)
at com.example.bogadan.runbabyrun.Main.Hit(Main.java:186)
at com.example.bogadan.runbabyrun.Main$4$1.run(Main.java:332)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)


where is the problem? i searched on Internet and i can't find the problem...

Answer

Just add the Result activity to AndroidManifest.xml

<activity android:name=".your_activity" android:label="sample_name"/>
Comments