问题描述
我有一个简单的Android应用程序来播放视频。我有一个包含几个按钮的主屏幕。如果preSS的按钮,它会播放视频。一切工作正常。
我的问题是,我的主屏有一个背景图片也有对一个按钮的图像。我有一个按钮,选择皮肤的应用程序。有三个选项。当我选择三个选项,背景图像和按钮图像会发生变化。现在,我想给皮肤(包括背景图片和按钮的图像)作为在稍后阶段不同的APK。当我安装这个APK应该显示为已经存在的皮肤。这是做到这一点的最简单的方法是什么?
感谢
我没有试图读取主题从其他APK,但我认为你可以使用这种策略。
-
找到你的主题包的设备。要做到这一点,你应该做一个命名规则或某些方法来检查这个包是否是你的主题APK与否。我假设你的名字APK主题为com.myapp.theme。????
- 如果你发现主题APK,从该应用程序读取资源文件
。我不知道如何做到这一点,但这个链接会帮助你。从另一个应用程序访问项目资产?
PackageManager PKGMGR = ctx.getPackageManager();名单< ApplicationInfo>应用程序= pkgMgr.getInstalledApplications(PackageManager.GET_META_DATA);对于(ApplicationInfo AI:应用程序){ 字符串PKGNAME = ai.packageName; 如果(pkgName.startsWith(com.myapp.theme){//这PKG是你的主题PKG //访问这个应用程序的资产 }}
FFF
I have a simple android app to play videos. I have a main screen containing few buttons. If you press the button it will play the videos. Everything works fine.
My problem is that my main screen have one background image also there is one image for buttons. i have one button to choose the skin for the app. There are three options. When I choose three options, the background image and button image will change. Now I want to give the skins (contains background image and button image) as separate apk at later stages. When I install this apk it should be shown with the already existing skin. Which is the easiest way to accomplish this?
Thanks
I didn't tried to read theme from other apk, but I think you can use this strategy.
find your theme package from device. To do this, you should make a naming rule or some method to check whether that package is your theme apk or not. I assume that you name theme apk as 'com.myapp.theme.????'
if you find theme apk, read asset file from that app. I don't know how to do this, but this link will help you. Access Assests from another application?
PackageManager pkgMgr = ctx.getPackageManager();
List<ApplicationInfo> apps = pkgMgr.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo ai : apps) {
String pkgName = ai.packageName;
if( pkgName.startsWith( "com.myapp.theme" ) { //this pkg is your theme pkg
//access asset of this app
}
}
fff
这篇关于Android的添加额外的皮肤作为单独的APK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!