简体   繁体   中英

Choosing minimum SDK and API level while developing an android application

I started developing an android application. While starting the project, I chose minimin SDK (API 15) as It was recommended and support more than 90% android in today's market. But when I develop an application, It shows all the API starting from 15 to latest one (23). 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.

Application shoud be tested on all Android versions supported. But first of all you should test on devices that most of your users have. That's Android 4.4 at the moment.

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

 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

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. That will support your deprecated api.

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

    StrictMode.setThreadPolicy(policy);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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