Suppose in my main app i have a layout "main_layout.xml" and in my skin(another app) app i have a layout "main_layout2.xml" .
Now how can i set setContentView(main_layout2)
in my main app if skin app is installed and if not installed then setContentView(R.layout.main_layout);
i know this much:
[In Theme package]
1. set action for activity, for example: my.package.theme
2. add all files you need for this theme
[In main app]
// Create intent with your action: my.package.theme
Intent intent = new Intent();
intent.setAction("my.package.theme");
// Get list of all installed packages with your themes
List<ResolveInfo> lresolve = pm.queryIntentActivities(intent, 0);
int size = lresolve.size();
for (int i = 0; i < size; i++) {
ApplicationInfo appInfo = lresolve.get
(i).activityInfo.applicationInfo;
try {
Resources resSkin = pm.getResourcesForApplication(appInfo);
int backres = resSkin.getIdentifier("my_background", "drawable",
appInfo.packageName);
// getting background from theme package
Drawable background = resSkin.getDrawable(backres);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
By above code i can change the image . But how to infiltrate a xml layout of an other app to main app.
please help me in this (a sample code or example links, it would be appreciated).
Thanks in advance.