android Programming Glossary: build.version.sdk_int
Using DiskLruCache in android 4.0 does not provide for openCache method http://stackoverflow.com/questions/10185898/using-disklrucache-in-android-4-0-does-not-provide-for-opencache-method Utils public static boolean isExternalStorageRemovable if Build.VERSION.SDK_INT Build.VERSION_CODES.GINGERBREAD return Environment.isExternalStorageRemovable.. cacheDir public static boolean hasExternalCacheDir return Build.VERSION.SDK_INT Build.VERSION_CODES.FROYO Remember to put uses permission android..
PreferenceActivity Android 4.0 and earlier http://stackoverflow.com/questions/10186697/preferenceactivity-android-4-0-and-earlier screen to the user you decide which one to start if Build.VERSION.SDK_INT 11 startActivity new Intent this PreferencesActivity.class else..
Android datepicker min max date before api level 11 http://stackoverflow.com/questions/10836679/android-datepicker-min-max-date-before-api-level-11 this.datePicker DatePicker findViewById R.id.xxxxx if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB picker is a DatePicker this.datePicker.setMinDate..
Access-Control-Allow-Origin Error At Android 4.1 http://stackoverflow.com/questions/11318703/access-control-allow-origin-error-at-android-4-1 improve this question you need to do something like if Build.VERSION.SDK_INT VERSION_CODES.JELLY_BEAN wv.getSettings .setAllowUniversalAccessFromFileURLs..
What is better: @SuppressLint or @TargetApi? http://stackoverflow.com/questions/14341042/what-is-better-suppresslint-or-targetapi T void executeAsyncTask AsyncTask T task T... params if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB task.executeOnExecutor AsyncTask.THREAD_POOL_EXECUTOR..
Android Speech Recognition as a service on Android 4.1 & 4.2 http://stackoverflow.com/questions/14940657/android-speech-recognition-as-a-service-on-android-4-1-4-2 switch msg.what case MSG_RECOGNIZER_START_LISTENING if Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN turn off beep sound target.mAudioManager.setStreamMute.. @Override public void onReadyForSpeech Bundle params if Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN mIsCountDownOn true mNoSpeechCountDown.start..
Using the Android RecognizerIntent with a bluetooth headset http://stackoverflow.com/questions/14991158/using-the-android-recognizerintent-with-a-bluetooth-headset public boolean start if mIsStarted mIsStarted true if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB mIsStarted startBluetooth else.. down. public void stop if mIsStarted mIsStarted false if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB stopBluetooth else stopBluetooth11..
How to retrieve the android sdk version? http://stackoverflow.com/questions/1882883/how-to-retrieve-the-android-sdk-version you the user visible version string i.e 1.5 1.6 2.0 while Build.VERSION.SDK_INT will give you a value from Build.VERSION_CODES that would be..
How to animate a slide in notification view that pushes the content view down http://stackoverflow.com/questions/19098083/how-to-animate-a-slide-in-notification-view-that-pushes-the-content-view-down @Override public void onGlobalLayout if Build.VERSION.SDK_INT 16 layout.getViewTreeObserver .removeGlobalOnLayoutListener..
Android Gallery on KitKat returns different Uri for Intent.ACTION_GET_CONTENT http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content share improve this question Try this if Build.VERSION.SDK_INT 19 Intent intent new Intent intent.setType image jpeg intent.setAction..
Download a file with Android, and showing the progress in a ProgressDialog http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog boolean isDownloadManagerAvailable Context context try if Build.VERSION.SDK_INT Build.VERSION_CODES.GINGERBREAD return false Intent intent.. to run you must use the android 3.2 to compile your app if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB request.allowScanningByMediaScanner..
How do you to retrieve dimensions of a view? Getheight() and Getwidth() always return zero http://stackoverflow.com/questions/4142090/how-do-you-to-retrieve-dimensions-of-a-view-getheight-and-getwidth-always-r 2 0 0 ViewTreeObserver obs tv.getViewTreeObserver if Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN obs.removeOnGlobalLayoutListener..
start android application info screen http://stackoverflow.com/questions/4421527/start-android-application-info-screen packageName Intent intent new Intent final int apiLevel Build.VERSION.SDK_INT if apiLevel 9 above 2.3 intent.setAction Settings.ACTION_APPLICATION_DETAILS_SETTINGS..
List View Footer Background on Android 2.3.3 http://stackoverflow.com/questions/6209114/list-view-footer-background-on-android-2-3-3 extends ListView private void makeTransparent if Build.VERSION.SDK_INT 9 try Method overscrollFooterMethod TransparentListView.class.getMethod..
How to store image retreived from url in a SQLite database? http://stackoverflow.com/questions/6815355/how-to-store-image-retreived-from-url-in-a-sqlite-database Set the Width Height of the ImageView. if Build.VERSION.SDK_INT 11 i.setLayoutParams new Gallery.LayoutParams 450 300 return..
Android SDK AsyncTask doInBackground not running (subclass) http://stackoverflow.com/questions/9119627/android-sdk-asynctask-doinbackground-not-running-subclass Void Void Void my_task new ASyncTask Void Void Void ... if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB my_task.executeOnExecutor AsyncTask.THREAD_POOL_EXECUTOR..
Using DiskLruCache in android 4.0 does not provide for openCache method http://stackoverflow.com/questions/10185898/using-disklrucache-in-android-4-0-does-not-provide-for-opencache-method Utils public static final int IO_BUFFER_SIZE 8 1024 private Utils public static boolean isExternalStorageRemovable if Build.VERSION.SDK_INT Build.VERSION_CODES.GINGERBREAD return Environment.isExternalStorageRemovable return true public static File getExternalCacheDir.. new File Environment.getExternalStorageDirectory .getPath cacheDir public static boolean hasExternalCacheDir return Build.VERSION.SDK_INT Build.VERSION_CODES.FROYO Remember to put uses permission android name android.permission.WRITE_EXTERNAL_STORAGE on your..
PreferenceActivity Android 4.0 and earlier http://stackoverflow.com/questions/10186697/preferenceactivity-android-4-0-and-earlier target At the point where you want to display the preference screen to the user you decide which one to start if Build.VERSION.SDK_INT 11 startActivity new Intent this PreferencesActivity.class else startActivity new Intent this OtherPreferencesActivity.class..
Android datepicker min max date before api level 11 http://stackoverflow.com/questions/10836679/android-datepicker-min-max-date-before-api-level-11 with min value Calendar this.calendar new GregorianCalendar this.datePicker DatePicker findViewById R.id.xxxxx if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB picker is a DatePicker this.datePicker.setMinDate this.calendar.getTimeInMillis else final..
Access-Control-Allow-Origin Error At Android 4.1 http://stackoverflow.com/questions/11318703/access-control-allow-origin-error-at-android-4-1
What is better: @SuppressLint or @TargetApi? http://stackoverflow.com/questions/14341042/what-is-better-suppresslint-or-targetapi behavior on older devices @TargetApi 11 static public T void executeAsyncTask AsyncTask T task T... params if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB task.executeOnExecutor AsyncTask.THREAD_POOL_EXECUTOR params else task.execute params Having..
Android Speech Recognition as a service on Android 4.1 & 4.2 http://stackoverflow.com/questions/14940657/android-speech-recognition-as-a-service-on-android-4-1-4-2 Message msg final MyService target mtarget.get switch msg.what case MSG_RECOGNIZER_START_LISTENING if Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN turn off beep sound target.mAudioManager.setStreamMute AudioManager.STREAM_SYSTEM true.. public void onPartialResults Bundle partialResults @Override public void onReadyForSpeech Bundle params if Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN mIsCountDownOn true mNoSpeechCountDown.start mAudioManager.setStreamMute AudioManager.STREAM_SYSTEM..
Using the Android RecognizerIntent with a bluetooth headset http://stackoverflow.com/questions/14991158/using-the-android-recognizerintent-with-a-bluetooth-headset The return value of startBluetooth or startBluetooth11 public boolean start if mIsStarted mIsStarted true if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB mIsStarted startBluetooth else mIsStarted startBluetooth11 return mIsStarted Should.. receivers and stop Sco audio connection and cancel count down. public void stop if mIsStarted mIsStarted false if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB stopBluetooth else stopBluetooth11 @return true if audio is connected through headset...
How to retrieve the android sdk version? http://stackoverflow.com/questions/1882883/how-to-retrieve-the-android-sdk-version this question The String Build.VERSION.RELEASE will give you the user visible version string i.e 1.5 1.6 2.0 while Build.VERSION.SDK_INT will give you a value from Build.VERSION_CODES that would be better to use if you want to compare against it programatically...
How to animate a slide in notification view that pushes the content view down http://stackoverflow.com/questions/19098083/how-to-animate-a-slide-in-notification-view-that-pushes-the-content-view-down vto.addOnGlobalLayoutListener new OnGlobalLayoutListener @Override public void onGlobalLayout if Build.VERSION.SDK_INT 16 layout.getViewTreeObserver .removeGlobalOnLayoutListener this else layout.getViewTreeObserver .removeOnGlobalLayoutListener..
Android Gallery on KitKat returns different Uri for Intent.ACTION_GET_CONTENT http://stackoverflow.com/questions/19834842/android-gallery-on-kitkat-returns-different-uri-for-intent-action-get-content this android android intent android gallery android contentresolver share improve this question Try this if Build.VERSION.SDK_INT 19 Intent intent new Intent intent.setType image jpeg intent.setAction Intent.ACTION_GET_CONTENT startActivityForResult..
Download a file with Android, and showing the progress in a ProgressDialog http://stackoverflow.com/questions/3028306/download-a-file-with-android-and-showing-the-progress-in-a-progressdialog true if the download manager is available public static boolean isDownloadManagerAvailable Context context try if Build.VERSION.SDK_INT Build.VERSION_CODES.GINGERBREAD return false Intent intent new Intent Intent.ACTION_MAIN intent.addCategory Intent.CATEGORY_LAUNCHER.. descrition request.setTitle Some title in order for this if to run you must use the android 3.2 to compile your app if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB request.allowScanningByMediaScanner request.setNotificationVisibility DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED..
How do you to retrieve dimensions of a view? Getheight() and Getwidth() always return zero http://stackoverflow.com/questions/4142090/how-do-you-to-retrieve-dimensions-of-a-view-getheight-and-getwidth-always-r LayerDrawable tv.getBackground ld.setLayerInset 1 0 tv.getHeight 2 0 0 ViewTreeObserver obs tv.getViewTreeObserver if Build.VERSION.SDK_INT Build.VERSION_CODES.JELLY_BEAN obs.removeOnGlobalLayoutListener this else obs.removeGlobalOnLayoutListener this First..
start android application info screen http://stackoverflow.com/questions/4421527/start-android-application-info-screen static void showInstalledAppDetails Context context String packageName Intent intent new Intent final int apiLevel Build.VERSION.SDK_INT if apiLevel 9 above 2.3 intent.setAction Settings.ACTION_APPLICATION_DETAILS_SETTINGS Uri uri Uri.fromParts SCHEME packageName..
List View Footer Background on Android 2.3.3 http://stackoverflow.com/questions/6209114/list-view-footer-background-on-android-2-3-3 import android.widget.ListView public class TransparentListView extends ListView private void makeTransparent if Build.VERSION.SDK_INT 9 try Method overscrollFooterMethod TransparentListView.class.getMethod setOverscrollFooter new Class Drawable.class..
How to store image retreived from url in a SQLite database? http://stackoverflow.com/questions/6815355/how-to-store-image-retreived-from-url-in-a-sqlite-database as width height are set. i.setScaleType ImageView.ScaleType.FIT_CENTER Set the Width Height of the ImageView. if Build.VERSION.SDK_INT 11 i.setLayoutParams new Gallery.LayoutParams 450 300 return i else i.setLayoutParams new Gallery.LayoutParams 125..
Android SDK AsyncTask doInBackground not running (subclass) http://stackoverflow.com/questions/9119627/android-sdk-asynctask-doinbackground-not-running-subclass I changed my code like this and problem is gone ASyncTask Void Void Void my_task new ASyncTask Void Void Void ... if Build.VERSION.SDK_INT Build.VERSION_CODES.HONEYCOMB my_task.executeOnExecutor AsyncTask.THREAD_POOL_EXECUTOR Void null else my_task.execute Void..
|