Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android add extra skin as separate APK

Tags:

android

skin

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

like image 611
Hashim MH Avatar asked Mar 10 '12 05:03

Hashim MH


1 Answers

I didn't tried to read theme from other apk, but I think you can use this strategy.

  1. 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.????'

  2. 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

like image 81
kingori Avatar answered Oct 18 '22 07:10

kingori