What if I want to release an update with higher minSDK than the one on the market?

后端 未结 1 1304
灰色年华
灰色年华 2020-12-10 08:00

I have released an app on the market with minSDK set to 4 (Android 1.6) but now I want to release an update with features unavailable in 1.

相关标签:
1条回答
  • 2020-12-10 08:18

    No they shouldn't be notified of the update. The market will filter the application out all together and they will no longer be able to see it or receive updates.

    If you want to add features that use a higher api level but not exclude user's of a lower api level you can use some reflection to enable this:

               public static Method getExternalFilesDir;        
    
                try {
                        Class<?> partypes[] = new Class[1];
            partypes[0] = String.class;
                        getExternalFilesDir = Context.class.getMethod("getExternalFilesDir", partypes);
                } catch (NoSuchMethodException e) {
                        Log.e(TAG, "getExternalFilesDir isn't available in this devices api");
                }
    

    This piece of code is saying:

    Within the Context.class have I got this method getExternalFilesDir (API level 9)

    If so instantiate the variable getExternalFilesDir as a reflective call to this method else leave it as null.

    Then later on you can simply do

         // If the user's device is API9 or above
         if(getExternalFilesDir != null){
           // Invoke is basically the same as doing Context.getExternalFilesDir(var1, var2);
           getExternalFilesDir.invoke(variable1, variable2);
         } else {
            // User cannot use this method do something else
         }
    

    Hope that helps

    0 讨论(0)
提交回复
热议问题