從我的包中的類,我嘗試在包B.啓動活動android.content.ActivityNotFoundException:無法找到明確的活動課的時候調用StartActivity()
它工作正常,當我嘗試這樣:
new Intent(getApplicationContext(), ClassB.class);
然而,當嘗試通過這種方式創建Intent
:
ComponentName componentName = ComponentName.unflattenFromString("com.example.package/.ClassB");
它提供了錯誤:**android.content.ActivityNotFoundException:** Unable to find explicit activity class {};
你在宣佈本次活動您AndroidManifest.xml
?我的問題是需要通過ComponentName
才能稱爲第二種方式。
儘管我已經提到了這個問題的所有相關循環,但沒有找到解決方案。此外,我宣佈我的表現像下面(否則我想它不會被通過第1種方法調用)OK:
<activity android:name="com.example.package.ClassB"
android:exported="true"
android:excludeFromRecents="true" />
請檢查是否可能幫助?這兩個軟件包也是同一個App的一部分。
你確定軟件包名稱是「com.example.package」嗎?是不是你在gradle中改變它的給定變體? – Selvin
你可以試試看:ComponentName.createRelative(「com.example.package」,「ClassB」); – X3Btel
@Selvin是,雙重保證.. –