I have target sdk set as 3.2 and min sdk as 2.2, how can I use strictmode in my application, as I understand it is introduced but cannot really understand how to start using it.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
My suggestion is two-fold:
First, add some baseline StrictMode code to your Application‘s
onCreate(). This lets you apply StrictMode to your entire app in an easy fashion (though you could put this code anywhere for more specific testing). There’s good sample code in the StrictMode docs.Second, detect the version of the SDK before trying to use StrictMode. This way, you only use StrictMode in API versions 9 or above – if you don’t do this check, you’ll crash your app on older versions of Android. You can easily detect the SDK version by looking at Build.VERSION.SDK_INT.
Optionally, you may want to only enable StrictMode when you’re testing. How you do this is up to you, though I’ve written up one solution for this in the past.