android - 尝试在 Android 中使用 appcenter Distribute

标签 android visual-studio-app-center-distribute

大家好,我按照指南做了

https://learn.microsoft.com/en-us/appcenter/sdk/distribute/android

 AppCenter.start(getApplication(), "real app secret ", Distribute.class);
 Log.e("Distribute","start worked for Dist without listener");

我在为我的应用程序登录的库的 onCreate 中执行此操作,我看到正在打印日志,但没有弹出对话框

任何想法可能是什么问题?

最佳答案

您是否实现了自定义监听器?它应该从下面的接口(interface)扩展。我已经提供了一个对我有用的例子!

Distribute.setListener(new AppCenterUpdateListener());
Distribute.setEnabled(true);
AppCenter.start(getApplication(),"secret", Distribute.class);


class AppCenterUpdateListener : DistributeListener {

override fun onReleaseAvailable(activity: Activity, releaseDetails: ReleaseDetails): Boolean {
    // Look at releaseDetails public methods to get version information, release notes text or release notes URL
    val versionName = releaseDetails.shortVersion
    val versionCode = releaseDetails.version
    val releaseNotes = releaseDetails.releaseNotes
    val releaseNotesUrl = releaseDetails.releaseNotesUrl

    // Build our own dialog title and message
    val dialogBuilder = AlertDialog.Builder(activity, R.style.alertDialogNoBar)
    dialogBuilder.setTitle("Version $versionName available!")
    dialogBuilder.setMessage(releaseNotes)

    // Mimic default SDK buttons
    dialogBuilder.setPositiveButton(com.microsoft.appcenter.distribute.R.string.appcenter_distribute_update_dialog_download) { _,_ ->
        Distribute.notifyUpdateAction(UpdateAction.UPDATE)
    }

    // We can postpone the release only if the update is not mandatory
    if (!releaseDetails.isMandatoryUpdate) {
        dialogBuilder.setNegativeButton(com.microsoft.appcenter.distribute.R.string.appcenter_distribute_update_dialog_postpone) { _,_ ->
            Distribute.notifyUpdateAction(UpdateAction.POSTPONE)
        }
    }
    dialogBuilder.setCancelable(false)
    dialogBuilder.create().show()

    // Return true if you are using your own dialog, false otherwise
    return true
}

关于android - 尝试在 Android 中使用 appcenter Distribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64008487/

相关文章:

visual-studio-app-center - 我们需要为 App Center 打开哪些 URL 才能用于内部应用程序

testflight - 我在哪里可以在 appcenter.ms testflight 集成中输入我的应用程序特定密码?

react-native - 有什么方法可以从 React Native 的 env 文件中获取 appcenter 配置

android - 在 android 中进行 Stripe 集成并创建 token

android - 哪种方法最适合C程序在Android中运行

java - 在不使用媒体提取器的情况下,无法在 Android 4.2 上对视频进行低级解码

android - Appcenter Android 版本无法安装在设备中

java - 在多 fragment View 页面中检索错误选择的单选按钮

java - 我可以根据变量而不是在 xml 中添加运行时按钮数量吗