更新可用消息自动出现 - android

时间:2014-09-27 12:25:04

标签: java android

我可以问你一个问题吗?

我构建了一个Android应用程序,但它不在Google Play商店中。我想在那里添加更新警报消息,所以我尝试WVersionManager - https://github.com/winsontan520/Android-WVersionManager。它显然在测试中运行,但点击“立即更新”按钮后没有任何反应。

主要问题是我在哪里可以添加我的应用程序apk链接 - 我上传了update_content_json_format.txt并且运行良好。该文本文件仅用于更新信息 -

{"version_code":2,"content":"Version 2.0
<p>New features:</p>
<li>Added feature A</li>
<li>Added feature B</li>
<li>Added feature C</li>
<li>Added feature D</li>
<li>Added feature E</li>
<li>Added feature F</li>
<li>Added feature G</li>"}

请指出我在哪里可以添加我的更新应用程序apk链接,这不是来自Playstore。

- 或 -

根据这个想法,我想知道每当我打开应用程序时如何自动显示更新可用对话框。

非常感谢!

关心,

1 个答案:

答案 0 :(得分:0)

哇..我对外部下载链接没问题!

我在原版上有所改变(有些代码没有使用,但我还不知道要删除)

package com.winsontan520.wversionmanager.sample;

import com.winsontan520.wversionmanager.sample.R;
import com.winsontan520.wversionmanager.library.WVersionManager;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class CheckVersionActivity extends Activity {

    // this is just a sample url to retrieve update content, the return content must follow the json format as stated in readme.md
    public final static String URL_VERSION_2 = "http://......."; // this link is refer to a static text file hosted using dropbox
    public final static String URL_VERSION_3 = "http://........";

    private EditText versionContentUrl;
    private EditText updateNowLabel;
    private EditText remindMeLaterLabel;
    private EditText ignoreThisVersionLabel;
    private EditText reminderTimer;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.check_version);

        versionContentUrl = (EditText) findViewById(R.id.versionContentUrl);
        updateNowLabel = (EditText) findViewById(R.id.updateNowLabel);
        remindMeLaterLabel = (EditText) findViewById(R.id.remindMeLaterLabel);
        ignoreThisVersionLabel = (EditText) findViewById(R.id.ignoreThisVersionLabel);
        reminderTimer = (EditText) findViewById(R.id.reminderTimer);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    public void onClickHandler(View v){
        switch(v.getId()){
        case R.id.use_version_2_button:
            versionContentUrl.setText(URL_VERSION_2);
            break;
        case R.id.use_version_3_button:
            versionContentUrl.setText(URL_VERSION_3);
            break;
        case R.id.check_version_button:
            checkVersion();
            break;
        }
    }

    private void checkVersion() {
        WVersionManager versionManager = new WVersionManager(this);

        versionManager.setVersionContentUrl(versionContentUrl.getText().toString());
        versionManager.setUpdateNowLabel(updateNowLabel.getText().toString());
        versionManager.setRemindMeLaterLabel(remindMeLaterLabel.getText().toString());
        versionManager.setIgnoreThisVersionLabel(ignoreThisVersionLabel.getText().toString());
        versionManager.setReminderTimer(Integer.valueOf(reminderTimer.getText().toString()));

        versionManager.checkVersion();

        versionManager.setUpdateNowLabel("Update Now!");
        versionManager.setRemindMeLaterLabel("Not Yet");
        versionManager.setIgnoreThisVersionLabel("Remind me soon");
        versionManager.setUpdateUrl("http://......../uploads/ExampleListActivity.apk"); // this is the link will execute when update now clicked. default will go to google play based on your package name.
        versionManager.setReminderTimer(10);
    }

}

但我仍然想知道每当我进入应用程序而不点击&#34时自动显示更新可用对话框;检查更新&#34;按钮。

关心,