简体   繁体   中英

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!

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

除非通过软件升级,否则不能更改已签名和密封的APK的启动器图标。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM