简体   繁体   English

在开发Android应用程序时选择最低的SDK和API级别

[英]Choosing minimum SDK and API level while developing an android application

I started developing an android application. 我开始开发一个android应用程序。 While starting the project, I chose minimin SDK (API 15) as It was recommended and support more than 90% android in today's market. 在启动项目时,我选择了minimin SDK(API 15),因为它被推荐,并且在当今市场上支持90%以上的android。 But when I develop an application, It shows all the API starting from 15 to latest one (23). 但是,当我开发一个应用程序时,它显示了从15到最新版本(23)的所有API。 Now, which one should I use for testing and developing the application. 现在,我应该使用哪一个来测试和开发该应用程序。 and some of the palette are also deprecated between API 15 to API 23. 在API 15和API 23之间不推荐使用某些调色板。

Application shoud be tested on all Android versions supported. 应在所有支持的Android版本上测试应用程序。 But first of all you should test on devices that most of your users have. 但是首先,您应该在大多数用户拥有的设备上进行测试。 That's Android 4.4 at the moment. 目前是Android 4.4。

it does show all APIs that you have but minimumSKD is there because it is the lowest SDK your app is to support and maxmum is the highest it is to go, if you find yourself in cases where an API is only on 23 and another is only on 15 your could first check which API the current device is running on and apply the right API call to it here is an example 它确实显示了您拥有的所有API,但是其中存在minimumSKD,因为它是您的应用程序所支持的最低SDK,而maxmum是它所能获得的最高SDK,如果您发现自己仅使用23个API,而另一个API仅在15号上,您可以先检查当前设备在哪个API上运行,并对其应用正确的API调用,这是一个示例

 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
                {
                    correctEmail.setImageDrawable(baseContext.getResources().getDrawable(R.drawable.ic_checked2));
                    correctEmail.setAnimation(AnimateViews.inFromRightAnimation(1000));
                    correctEmail.setVisibility(View.VISIBLE);
                }else{

                    correctEmail.setImageDrawable(baseContext.getResources().getDrawable(R.drawable.ic_checked2, baseContext.getTheme()));
                    correctEmail.setAnimation(AnimateViews.inFromRightAnimation(1000));
                    correctEmail.setVisibility(View.VISIBLE);
                }

so like in this example to get drawable on lollipop you need to give it the theme but in lower APIs you dont, thats how you support many devices 因此,就像在此示例中一样,要在棒棒糖上可绘制,您需要为其指定theme但在较低的API中,您就不需要这样,这就是您支持许多设备的方式

Then you have to text your application to only minimum and maximum versions of os (API 15 and API 23) for testing and add below code to your activity. 然后,您仅需将应用程序文本发送到最低和最高版本的os(API 15和API 23)以进行测试,并将以下代码添加到您的活动中。 That will support your deprecated api. 那将支持您已弃用的api。

if (Build.VERSION.SDK_INT >= 15) {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
            .permitAll().build();

    StrictMode.setThreadPolicy(policy);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM