且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android应用程序无法在市场:如何推送更新?

更新时间:2021-09-23 02:11:18

在你的应用程序开始检查可用的版本,你可以使用一个AlertDialog要求进行升级。

at the start of your app check the available version, the you can use an AlertDialog to ask for the upgrade.

阅读:: Is有没有办法在Android上自动更新的应用程序?

和这是一个AlertDialog例子::

and this is an AlertDialog example::

    if (ConfigXML_app_version> myapp_version){
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Upgrade");
        builder.setMessage("Update available, ready to upgrade?");
        builder.setIcon(R.drawable.icon);
        builder.setCancelable(false);
        builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse(app_link));
                startActivity(intent);               
                finish();
            }
        });
        builder.setNegativeButton("Nop", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        AlertDialog alert = builder.create();
        alert.show();

    }