ActivityNotFoundException?

后端 未结 10 733
滥情空心
滥情空心 2020-12-01 14:25

I am getting an ActivityNotFoundException in the following code:

Main.java

Intent intent = new Intent();
     intent.setAction(\"com.tes         


        
相关标签:
10条回答
  • 2020-12-01 15:16

    I found a solution to this problem... I´m using 2 modules in a android studio project, the thing here is that I needed to add the activity to the main manifest file

    <activity android:name="com.HeadApp.ARTry.UnityPlayerActivity"
              android:clearTaskOnLaunch="false" android:label="@string/app_name"
              android:screenOrientation="portrait" 
              android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
    />
    

    I had that in the unity activity manifest, I just copied the activity and paste it in the main manifest and that was it, hope it helps, eve been struggling a lot with this for the past 3 weeks

    0 讨论(0)
  • 2020-12-01 15:17

    Add a . (dot) before your activity name in Android Manifest. So it should be android:name=".WordsToSpeakMainActivity"

    0 讨论(0)
  • 2020-12-01 15:22

    I've had this issue too, as perfectly concisely described by jpahn.

    the period at the front did not give any help to me.

    even with exactly this (a copy of the original question including edits), I would still get ActivityNotFoundException.

    Main.java

    Intent intent = new Intent();
     intent.setAction("com.test.app.TEST");
     startActivity(intent); // ActivityNotFoundException
    

    Manifest.xml

    <activity android:name=".MainActivity" android:theme="@android:style/Theme.Dialog">
        <intent-filter>
            <action android:name="com.test.app.TEST" />
        </intent-filter>
    </activity>
    

    This was resolved, after much trial-and-error, by simply adding this to the intent-filter in the manifest:

    <category android:name="android.intent.category.DEFAULT" />
    

    So the final manifest file contained:

    <activity android:name=".MainActivity" android:theme="@android:style/Theme.Dialog">
        <intent-filter>
            <action android:name="com.test.app.TEST" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    
    0 讨论(0)
  • 2020-12-01 15:23

    At the very top of your AndroidManifest.xml, you'll see the package attribute

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.android.example"
    

    and then, in the activity tag, you'll see the name attribute:

    <activity
                android:name=".Something"
    

    Make sure that the package name and activity name, when joined together, make the full package specification of your Activity i.e.

    com.android.example + .Something = com.android.example.Something

    Otherwise, you'll get a ActivityNotFoundException.

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