2017-08-16 42 views
1

我有兩類:的Android快捷鍵 - 意圖不打開應用程序

1)公共類ClassA的延伸ClassB的

2)公共抽象類ClassB的延伸AppCompatActivity ...

對於這兩個類,我使用下面的代碼。 ClassA的作品(我得到一個logcat,onCreate被擊中),但ClassB沒有。它返回「應用程序未安裝」,這讓我想,我的targetPackage是錯誤的,但ClassA的工作,所以我感到困惑。是因爲classB是抽象的嗎?

<shortcut 
    android:shortcutId="..." 
    android:enabled="true" 
    android:icon="..." 
    android:shortcutShortLabel="..." 
    android:shortcutLongLabel="..." 
    android:shortcutDisabledMessage="..."> 
    <intent 
     android:action="..." 
     android:targetPackage="this.is.example.X" // where X is product flavor 
     android:targetClass="this.is.example.ClassA" /> 
    <categories android:name="..." /> 
</shortcut> 

回答

1

這不可能創建活動類的快捷方式。

+0

謝謝,不知道!有其他選擇嗎?我有三堂課。 ClassChild1(電話),ClassChild2(平板電腦)和ClassParent。 ClassChild1和ClassChild2都擴展了ClassParent。如何構建手機和平板電腦的快捷方式意圖? – PeteWonder

+0

@Pete在捷徑的情況下,沒有其他選擇。請記住,您只能爲App的清單中聲明的​​公共意圖創建快捷方式。 –