Java 来自不同包的启动器的Activity Intent筛选器操作名称
我糊涂了 我有两个来自不同包的活动,比如“com.exampleone.a”和“com.exampleon.b”。他们在同一个项目下 在单清单xml中,由于效率原因,我选择将“com.exampleone”声明为包,即Java 来自不同包的启动器的Activity Intent筛选器操作名称,java,android,android-intent,manifest,launcher,Java,Android,Android Intent,Manifest,Launcher,我糊涂了 我有两个来自不同包的活动,比如“com.exampleone.a”和“com.exampleon.b”。他们在同一个项目下 在单清单xml中,由于效率原因,我选择将“com.exampleone”声明为包,即 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.exampleone" ....../> 碰巧(是的,生活)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exampleone"
....../>
碰巧(是的,生活),我最终决定使用活动“com.exampletwo.b”作为启动器。所以我试着把它变成一个发射器
<intent-filter>
<action android:name="com.exampletwo.b" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
…这不起作用(它给出了“未找到启动器活动”错误)。我不能把这个动作重命名为
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
…因为这样我就很难引用此活动(请注意,在整个项目中,我一直在使用“com.exampletwo.b”作为我的意图)
有没有一种方法可以让启动器工作,最好不用重命名任何东西
我想我可以通过创建一个虚拟启动器活动来实现这一点,但是有没有更简单的方法来解决这个问题呢?为什么不从中创建一个活动呢?您可以选择其他活动来启动。 类似于LauncherActivity,FromOnePackageAct,FromTwoPackageAct。 然后在LauncherActivity中,您可以跳转到其他:
public class LauncherActivity...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, FromOnePackageAct.class);//here´s the trick
from.startActivity(intent);
// from.finish(); this is optional
希望这能给你一个想法:-)
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
public class LauncherActivity...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, FromOnePackageAct.class);//here´s the trick
from.startActivity(intent);
// from.finish(); this is optional