资源res = mPackageManager.getResourcesForApplication(" com.packagename");不工作6.0及以下

时间:2018-06-04 09:20:02

标签: android

6.0及以下的ResourceNotFound异常.am试图从另一个应用程序访问drawable。在我的ccase中,我想从另一个应用程序中应用主题。例如启动器应用程序。

方法:1

background-position

方法:2

    try {

                String mDrawableName = "icon";

                Resources mApk1Resources = manager.getResourcesForApplication(package_name);
                int mDrawableResID = mApk1Resources.getIdentifier("icon", "drawable", package_name);
                Drawable myDrawable = mApk1Resources.getDrawable(mDrawableResID);

                if (myDrawable != null) {
                    data.add(new DataModel("" + app_name, myDrawable, package_name));
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

0 个答案:

没有答案