Yangjing Zhang
Yangjing Zhang

Reputation: 69

Sign APK on Client Phone

This is my first question on StackOverflow, and my english is poor, so please :D. I do this just for fun. I want to change the icon per user, letting users change the icon of the app. I think if I want to do this, I must read the apk self, unzip it, change che drawable/icon.png and rebuild it, at last to sign. I try some code, but failed. The import reason is that, package sun.securate.* is not in Android Java framework. I write some code to do this, but it failed-_- Who can help me? I can share my already written code. Help me,Please!

Upvotes: 1

Views: 251

Answers (2)

havexz
havexz

Reputation: 9590

Well another work around will be to create shortcut icon for Home Screen which launches the same Activity as the launcher. With this your launcher icon in drawer will be the actual one but on the home screen you will have different icon. You can also explore the idea of creating shortcut for other apps if you know the package info.

Ref:

For package info here are the doc.

PackageManager pkgMgr = getPackageManager();

For creating short cut here is the snippet (this is just for illustration):

    // Setting the intent class ActivityClassToLaunch you need to try PackageManager
    Intent i = new Intent(activity, ActivityClass.class);

    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_LAUNCHER);

    Intent result = new Intent();
    result.putExtra(Intent.EXTRA_SHORTCUT_INTENT, i);

    result.putExtra(Intent.EXTRA_SHORTCUT_NAME, activity.getString(R.string.app_name));

    ShortcutIconResource iconResource = null;

    iconResource = ShortcutIconResource.fromContext(activity, R.drawable.new_app_icon);

    result.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);

    result.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
    activity.sendBroadcast(result);

If you just want user to change the app icon, why dont you load the icon from the SD card. And the icon that you ship with your package will be there if no icon is specified by user.

Here is the snippet that can help you.

onCreate(...)
  setContentView(...); 
  setFeatureDrawable(Window.FEATURE_LEFT_ICON, 
     <your_drawable>); 
....
}

If this does not work, try calling setFeatureDrawable before setContentView

Upvotes: 1

Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53687

You cannot change the launcher icon of a signed-and-sealed APK, except through a software upgrade.

Upvotes: 0

Related Questions