0

i tried to convert activity into fragment and the code is without "errors" in android studio, but the app crashes when the converted activity is pressed.

part of code i think its causing error:

Btnregister.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Intent myIntent = new Intent(view.getContext(), Register.class);
            startActivityForResult(myIntent, 0);
            getActivity().finish();
         }});

and my error output:

04-19 15:54:33.644  32229-32229/com.app.test E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.app.test, PID: 32229
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.app.test/com.app.test.ChangePassword}; have you declared this activity in your AndroidManifest.xml?

could this part of code that i pasted cause this problem ?

RidRoid
  • 961
  • 3
  • 16
  • 39
Sh4rk162
  • 17
  • 4

1 Answers1

0

Make sure that all your activities registered in manifest. howto for sliding tabs

Raiv
  • 5,731
  • 1
  • 33
  • 51
  • should i register fragment in manifest because i dont have any activity, only mainactivity and it is registered. – Sh4rk162 Apr 19 '15 at 14:10
  • 2
    @Sh4rk162, You can't "start" Fragments via Intents – Egor Apr 19 '15 at 14:10
  • what is the type of `Register.class`? And what is `com.app.test.ChangePassword`? – Raiv Apr 19 '15 at 14:11
  • Intents works only with activities. If you want to switch fragments in one activity use `FragmentManager`, if you want start activity for result - add another activities which displays your fragments on start. – Raiv Apr 19 '15 at 14:17
  • @Raiv maybe a simpler question how can i make slider menu, with login/register and "news feed" the easiest way. fragments or combination of fragments and activities is it something like this? http://stackoverflow.com/questions/12074608/how-do-i-start-an-activity-from-within-a-fragment – Sh4rk162 Apr 19 '15 at 14:21
  • I added guide for sliding tabs in my answer – Raiv Apr 19 '15 at 14:23
  • yes i saw but i want to know if its possible to do it on the way i pasted the link to run activity inside fragment, because its easier to understand thanks – Sh4rk162 Apr 19 '15 at 14:24
  • yes,you can run activity from fragment. But not fragment from fragment. – Raiv Apr 19 '15 at 14:26