-1

How can I solve this types of issue from my android device when I update application if any one then not updated application from Google Play store, so what I do? Please tell me and solve this issue.

4

1 回答 1

0

if I understand you correctly you want to force updates on your users.

this can be achieved in a pretty simple way if your app is connected to your own server for data transfer.

all you have to do is send a key to your sever for authentication (in addition to the user and password or whatever is sent).

private static final String [] myKey = new String [] {"str1", "str2", "str3", "str4"};

public boolean login(String user, String password) {

    boolean loginSuccessful ServerModule.sendRequest(user, SHA1(password + TextUtils.join("-", myKey));
    if(loginSuccessful) {
          return true;
    }
    return false;
}

the SHA1 function is taken from this answer:

private static String convertToHex(byte[] data) {
    StringBuilder buf = new StringBuilder();
    for (byte b : data) {
        int halfbyte = (b >>> 4) & 0x0F;
        int two_halfs = 0;
        do {
            buf.append((0 <= halfbyte) && (halfbyte <= 9) ? (char) ('0' + halfbyte) : (char) ('a' + (halfbyte - 10)));
            halfbyte = b & 0x0F;
        } while (two_halfs++ < 1);
    }
    return buf.toString();
}

public static String SHA1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
    MessageDigest md = MessageDigest.getInstance("SHA-1");
    md.update(text.getBytes("iso-8859-1"), 0, text.length());
    byte[] sha1hash = md.digest();
    return convertToHex(sha1hash);
}

every time you send an update you change the key in the app and in the server and now your users are forced to update.

you should probably add a UI that prompts if the user has an old key and send them to the app in the Google Play site. You can do this with an intent.

final String appName = "com.example";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName)));

(this code was taken from this answer)

于 2012-11-27T07:02:44.310 回答