Cavallari Rodrigo
Cavallari Rodrigo

Reputation: 13

ActivityNotFoundException even actions declared for Fragment

I have the code below:

public class Fragment1 extends Fragment implements View.OnClickListener {

    Button button;

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        if(container == null )
            return null;

        View view = (LinearLayout)inflater.inflate(R.layout.fragment1_layout, container, false);
        button = (Button) view.findViewById(R.id.button);
        button.setOnClickListener(this);
        return view;
    }

    @Override
    public void onClick(View v) {

        if(v.getId() == R.id.button) {
            startActivity(new Intent(getActivity().getApplicationContext(), Fragment3.class));
        }
    }
}

I'm starting on Android, I even declaring an activity in manifext.xml as:

activity android:name="pachage...destiny_fragment"

continuous showing

E/AndroidRuntime﹕ FATAL EXCEPTION: main
    android.content.ActivityNotFoundException: Unable to find explicit activity class {eguias.delogic.com.br.eguiasmobile/eguias.delogic.com.br.eguiasmobile.Fragment3}; have you declared this activity in your AndroidManifest.xml?
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1541)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1416)
            at android.app.Activity.startActivityForResult(Activity.java:3351)
            at android.app.Activity.startActivityForResult(Activity.java:3312)
            at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:826)
            at android.support.v4.app.Fragment.startActivity(Fragment.java:896)
            at eguias.delogic.com.br.eguiasmobile.Fragment1.onClick(Fragment1.java:37)
            at android.view.View.performClick(View.java:4084)
            at android.view.View$PerformClick.run(View.java:16966)
            at android.os.Handler.handleCallback(Handler.java:615)
            at android.os.Handler.dispatchMessage(Handler.java:92)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4745)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)

The application run normally but the error "android.content.ActivityNotFoundException" always show in logcat.

Thanks.

Upvotes: -2

Views: 1624

Answers (2)

ahemad Ali
ahemad Ali

Reputation: 1

main

    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.shamsan.droplivelast1/com.shamsan.droplivelast1.Reqlist}; have you declared this activity in your AndroidManifest.xml?
 at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1556)
 at android.app.Instrumentation.execStartActivity(Instrumentation.java:1431)
 at android.app.Activity.startActivityForResult(Activity.java:3417)
at android.support.v4.app.BaseFragmentActivityJB.startActivityForResult(BaseFragmentActivityJB.java:50)

Upvotes: 0

Sar
Sar

Reputation: 560

Your Fragment3.class should extend Activity and this should be declared in AndroidManifest.xml.

Upvotes: 0

Related Questions