android.content.ActivityNotFoundException:

前端 未结 24 1873
一生所求
一生所求 2020-11-22 10:38

I am getting this exception while I am trying to call an activity from another one. The complete exception is

android.content.ActivityNotFoundExcept

相关标签:
24条回答
  • 2020-11-22 11:18

    Looking at the documentation here what you want is:

    intent.setClassName("com.x.y", "className");
    
    0 讨论(0)
  • 2020-11-22 11:19

    Yeah I got this problem too. I refreshed the project. And then, everything works fine.

    0 讨论(0)
  • 2020-11-22 11:20

    My solution to this error was to add a package name in front of the name in manifest.

    I had the following activities:

    • id.scanner.main.A1

    • id.scanner.main.gallery.A2

    My manifest contained the following:

    <activity android:name=".A1" ....></activity>
    <activity android:name=".A2" ....></activity>
    

    This solved the problem:

    <activity android:name=".A1" ....></activity>
    <activity android:name="gallery.A2" ....></activity>
    
    0 讨论(0)
  • 2020-11-22 11:22

    Hey, you need to use another form of Intent constructor. This will surely solve your issue within a second:

    Example:

    Intent inte=new Intent(getBaseContext(),"your class name with .class extension ");
    
    startActivity(inte);
    

    This works perfectly and I checked this code, its working properly.

    0 讨论(0)
  • 2020-11-22 11:22

    This works if you have an Activity object (which you need to launch):

    intent.setClassName(CallingActivity.this, activityToLaunch.getComponentName().getClassName());
    
    0 讨论(0)
  • 2020-11-22 11:22

    Try using the following:

    intent.setClassName("com.x.y", "com.x.y.className");
    

    This works for me

    0 讨论(0)
提交回复
热议问题