I have the following code in one of my apps...
... where 'ctx' is the application context.
There are two apps in this arrangement: the first is the 'main app' where the above code lives. The second is a 'skin app' which contains some layout and image resources that I'm trying to access.
The main app is NOT currently signed, and does NOT have a shared user id associated with it. It's a test version of an app that's already available in the Market, and I've read that when you add a shared user id to a Market app that didn't previously have one, all kinds of problems can occur.
The skin app IS signed, and DOES have a shared user id. The idea is that, in the future, all skin apps for my main app would have the same signature and shared user id, so I can get a list of them when my main app configuration activity runs.
Both apps are installed on my phone. And I've verified that '/data/system/packages.xml' has both packages and the shared user id defined. I also checked, double-checked, and triple-checked the spelling on my shared user id.
But when I make the call to getUidForName(), and pass it the shared user id, I'm getting a value of '-1'.
Any ideas what might be going on here? Would signing my main app (as it would be in a production environment) make a difference? Will this whole setup work ONLY if my main app runs with the same shared user id as the skin apps? Is there a problem with using the application context of my main app?
Thanks,
Corporate Dog
Code:
public static String[] getSkinPackageArray(Context ctx) {
Resources res = ctx.getResources();
String sharedUserId = res.getString(R.string.skin_shared_user_id);
PackageManager pckmgr = ctx.getPackageManager();
int uid = android.os.Process.getUidForName(sharedUserId);
if (uid >= 0) {
return pckmgr.getPackagesForUid(uid);
}
return null; //No packages found
}
There are two apps in this arrangement: the first is the 'main app' where the above code lives. The second is a 'skin app' which contains some layout and image resources that I'm trying to access.
The main app is NOT currently signed, and does NOT have a shared user id associated with it. It's a test version of an app that's already available in the Market, and I've read that when you add a shared user id to a Market app that didn't previously have one, all kinds of problems can occur.
The skin app IS signed, and DOES have a shared user id. The idea is that, in the future, all skin apps for my main app would have the same signature and shared user id, so I can get a list of them when my main app configuration activity runs.
Both apps are installed on my phone. And I've verified that '/data/system/packages.xml' has both packages and the shared user id defined. I also checked, double-checked, and triple-checked the spelling on my shared user id.
But when I make the call to getUidForName(), and pass it the shared user id, I'm getting a value of '-1'.
Any ideas what might be going on here? Would signing my main app (as it would be in a production environment) make a difference? Will this whole setup work ONLY if my main app runs with the same shared user id as the skin apps? Is there a problem with using the application context of my main app?
Thanks,
Corporate Dog