是否可以自定义或更改 android 应用程序卸载消息?

Is it possible to customize or change the android app uninstall message?

在我的 android 应用程序中,我正在使用以下代码卸载应用程序:

Intent intent = new Intent(Intent.ACTION_DELETE);
intent.setData(Uri.parse("package:com.ubercab"));
startActivity(intent);

虽然它工作正常,但是否可以将消息 "Do you want to uninstall the app?" 更改为自定义的内容?

我可以在卸载之前有另一个对话框,但我只是想知道是否可以自定义此文本。

不,您不能更改第三方代码显示的文本,包括像这样的系统对话框。

不,您不能自定义卸载消息。

正如您在 PackageInstaller 的 UninstallerActivity 中看到的,该消息是从应用程序的资源中获取的,不可自定义:

UserManager userManager = UserManager.get(getActivity());
if (dialogInfo.allUsers && userManager.getUserCount() >= 2) {
    messageBuilder.append(getString(R.string.uninstall_application_text_all_users));
} else if (!dialogInfo.user.equals(android.os.Process.myUserHandle())) {
    UserInfo userInfo = userManager.getUserInfo(dialogInfo.user.getIdentifier());
    messageBuilder.append(
            getString(R.string.uninstall_application_text_user, userInfo.name));
} else {
    messageBuilder.append(getString(R.string.uninstall_application_text));
}

这些是 string.xml 中可用的字符串:

<string name="uninstall_application_text">Do you want to uninstall this app?</string>
<string name="uninstall_application_text_all_users">Do you want to uninstall this app for <b>all</b> users?  The application and its data will be removed from <b>all</b> users on the device.</string>
<string name="uninstall_application_text_user">Do you want to uninstall this app for the user <xliff:g id="username">%1$s</xliff:g>?</string>