【问题标题】:Can you restrict a specific Android API version from running/downloading app from googlePlay store?您可以限制特定的 Android API 版本从 Google Play 商店运行/下载应用程序吗?
【发布时间】:2014-01-13 19:17:40
【问题描述】:

好的,我正在开发并计划发布的应用程序遇到了这个问题,但问题只发生在一个版本的 android SDK(版本 4.1.1 API 16)上。

我可以限制 JUST android 版本 4.1.1 API 16 下载和运行我的应用吗?

我知道 googlePlay 有一个限制某些设备列表,但问题是由于操作系统版本而不是设备而发生的,至少从调试来看是这样的......

我也知道manifest文件中有uses-sdk属性:

<uses-sdk android:minSdkVersion="integer"
          android:targetSdkVersion="integer"
          android:maxSdkVersion="integer" />

但是将 android:minSdkVersion 设置为 17 会太高而且无法提供给许多用户,我还做了很多工作来使应用程序向后兼容并在 3.0 之前的设备上正常工作,这只是这个 android 版本4.1.1 给我带来麻烦的 API 16...

请帮忙!谢谢!

编辑:这是我当前在我的应用清单中使用的 SDK:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

使用相关代码编辑

//button listener for the number buttons. Each button will display a number 1 - 10
//upon clicking the button the number that is displayed on the button will be
//added to what is displayed in the textView
//
//mCurrentWorkingText is the current expression that is being added updated.
View.OnClickListener genericNumberButtonListener = new View.OnClickListener() {

    @Override
    public void onClick(View v) {
    //cast the incoming view to a textView so we can get
    //the text the button displays
        TextView textView = (TextView) v;
        String textFromButton = textView.getText().toString();

        if (mCurrentWorkingText.length() == 0) {
            mWorkingTextView.setText(mWorkingTextView.getText()
                    .toString().concat(textFromButton));
            mCurrentWorkingText = textFromButton;
        } else {
                    // if the working TextView isn't zero we need to
                    // append
                    // the
                    // textFromButton to what is already there.
                    mWorkingTextView.setText(mWorkingTextView.getText()
                            .toString().concat(textFromButton));
                    mCurrentWorkingText = mCurrentWorkingText
                            .concat(textFromButton);


        }
    }
};

使用问题日志进行编辑

字符串在最后一条日志语句中几乎随机变为完全随机数。

【问题讨论】:

  • 描述一下这个问题怎么样?可能有一个修复。
  • 同意 Simon 的观点,经常有特定版本的修复可以通过Build.VERSION.SDK_INT 以编程方式触发,你应该寻找这个而不是在这里采取简单的方法;)
  • 修复会很好,但我已经尝试了 几乎 一切...这是问题所在:我有一个自定义按钮范围为 0 到 10 的视图和一个 textView单击特定按钮后显示按钮文本。很多时候,当单击按钮时,已输入和显示的数字只是随机更改为完全随机的不同数字。示例:TextView 显示“1777238”然后单击“4”将其附加到 textViews 字符串,但 textViews 字符串更改为几乎随机的数字,如“533323455”。任何帮助表示赞赏!
  • 这听起来很像你的错误,我猜操作系统版本是一个红鲱鱼。请张贴相关代码。我真的很难想象一个 Android 操作系统错误如此灾难性,它会导致您描述的症状。
  • 更新了按钮侦听器代码,将按钮显示的数字附加到 textView。

标签: java android google-play android-manifest android-version


【解决方案1】:

您可以阻止应用运行。

不,您不能阻止应用程序在minSDKVersionmaxSDKVersion/targetSDKVersion 之间的 API 上下载

你可以这样检查:

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD &&         android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.HONEYCOMB) {
 
 // For gingerbread but lesser than HONEYCOMB, show a dialog or something and close the app
 finish();

}

【讨论】:

    【解决方案2】:

    所以我遇到的问题是由我使用的pageTransformer 引起的。 Android 4.1.1 真的不喜欢它。我不知道为什么,但我所知道的是,如果您使用带有自定义视图的 pageTransformer 和 ActionBarSherlock,则在使用 pageTransformer 为翻页添加动画时最好小心。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多