ActivityNotFoundException?ActivityNotFoundException

2023-09-12 22:39:56 作者:花开成海ゞ思念成灾

我正在一个 ActivityNotFoundException 在以下code:

Main.java

 意向意图=新的意图();
     intent.setAction(com.test.app.TEST);
     startActivity(意向); // ActivityNotFoundException
 

的Manifest.xml

 <活动机器人:MainActivity名称=机器人:主题=@安卓风格/ Theme.Dialog>
        <意向滤光器>
            <作用机器人:名称=com.test.app.TEST/>
        &所述; /意图滤光器>
< /活性GT;
 

解决方案

我有这个问题也一样,完全由jpahn简明描述。

在前面的时间没有给我提供任何帮助。

即使正是这种(包括修改原来的问题复印件),我仍然会得到ActivityNotFoundException。

Main.java

 意向意图=新的意图();
 intent.setAction(com.test.app.TEST);
 startActivity(意向); // ActivityNotFoundException
 
英国脱欧 汇讯网

的Manifest.xml

 <活动机器人:MainActivity名称=机器人:主题=@安卓风格/ Theme.Dialog>
    <意向滤光器>
        <作用机器人:名称=com.test.app.TEST/>
    &所述; /意图滤光器>
< /活性GT;
 

这得到解决,经过多次试验和错误,通过简单地添加这对意图过滤器清单:

 <类机器人:名称=android.intent.category.DEFAULT/>
 

所以最终的清单文件包含:

 <活动机器人:MainActivity名称=机器人:主题=@安卓风格/ Theme.Dialog>
    <意向滤光器>
        <作用机器人:名称=com.test.app.TEST/>
        <类机器人:名称=android.intent.category.DEFAULT/>
    &所述; /意图滤光器>
< /活性GT;
 

I am getting an ActivityNotFoundException in the following code:

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>

解决方案

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>