簡體   English   中英

從另一個APK訪問的布局無法訪問其可繪制資源

[英]layout accessed from another APK could'nt access its drawable resources

我通過從其服務訪問applicationInfo並通過packageManager獲取資源來訪問另一個APK的布局。 如果在布局中僅指定textView和Button,則它可以正常工作。 但是拋出Resource not found Exception如果在訪問的布局中使用了任何可繪制的資源,則Resource not found Exception

這是我訪問布局的代碼

ApplicationInfo info = packageManager.getApplicationInfo( packageName, 0 );
Resources res = packageManager.getResourcesForApplication( info );
XmlResourceParser xres = res.getLayout( 0x7f030000 );

您好朋友,請嘗試此。

 PackageManager manager = getPackageManager();
 resources = manager.getResourcesForApplication(packName);

 int resID = resources.getIdentifier("image1", "drawable", packName);
 Log.d(TAG, "resID = " + resID);
 Drawable image = getResources().getDrawable(resID);
 Log.d(TAG, "resID = " + resID);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM