[英]Activity Intent-Filter Action Name for Launcher from Different Package
我很迷惑。
我有兩個來自不同軟件包的活動,比方說“ com.exampleone.a”和“ com.exampletwo.b”。 他們在同一個項目下。
在單清單xml中,由於效率原因,我選擇將“ com.exampleone”聲明為包,即
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.exampleone"
....../>
因此,對於其他活動的意圖過濾器,我使用...
<intent-filter>
<action android:name="com.exampletwo.b" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
因此,在我的程序中,當我想轉到com.exampletwo.b時,我將使用...
Intent myIntent = new Intent("com.exampletwo.b");
startActivity(myIntent);
碰巧發生了(是的,生命),我最終決定必須使用活動“ 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
希望這可以為您提供一個想法:-)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.