Get Android API level of phone currently running my application [duplicate]

Check android.os.Build.VERSION, which is a static class that holds various pieces of information about the Android OS a system is running. If you care about all versions possible (back to original Android version), as in minSdkVersion is set to anything less than 4, then you will have to use android.os.Build.VERSION.SDK, which is a String that … Read more

List of Android permissions normal permissions and dangerous permissions in API 23? [duplicate]

As of API level 23, the following permissions are classified as PROTECTION_NORMAL: ACCESS_LOCATION_EXTRA_COMMANDS ACCESS_NETWORK_STATE ACCESS_NOTIFICATION_POLICY ACCESS_WIFI_STATE BLUETOOTH BLUETOOTH_ADMIN BROADCAST_STICKY CHANGE_NETWORK_STATE CHANGE_WIFI_MULTICAST_STATE CHANGE_WIFI_STATE DISABLE_KEYGUARD EXPAND_STATUS_BAR GET_PACKAGE_SIZE INSTALL_SHORTCUT INTERNET KILL_BACKGROUND_PROCESSES MODIFY_AUDIO_SETTINGS NFC READ_SYNC_SETTINGS READ_SYNC_STATS RECEIVE_BOOT_COMPLETED REORDER_TASKS REQUEST_IGNORE_BATTERY_OPTIMIZATIONS REQUEST_INSTALL_PACKAGES SET_ALARM SET_TIME_ZONE SET_WALLPAPER SET_WALLPAPER_HINTS TRANSMIT_IR UNINSTALL_SHORTCUT USE_FINGERPRINT VIBRATE WAKE_LOCK WRITE_SYNC_SETTINGS and Dangerous permissions : READ_CALENDAR WRITE_CALENDAR CAMERA READ_CONTACTS WRITE_CONTACTS … Read more

Changing API level Android Studio

When you want to update your minSdkVersion in an existent project… Update build.gradle(Module: app) – Make sure is the one under Gradle Script and it is NOT build.gradle(Project: yourproject). An example of build.gradle: apply plugin: ‘com.android.application’ android { compileSdkVersion 28 buildToolsVersion “28.0.2” defaultConfig { applicationId “com.stackoverflow.answer” minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName “1.0” } … Read more

Environment.getExternalStorageDirectory() deprecated in API level 29 java

Use getExternalFilesDir(), getExternalCacheDir(), or getExternalMediaDirs() (methods on Context) instead of Environment.getExternalStorageDirectory(). Or, modify mPhotoEditor to be able to work with a Uri, then: Use ACTION_CREATE_DOCUMENT to get a Uri to a location of the user’s choosing, or Use MediaStore, ContentResolver, and insert() to get a Uri for a particular type of media (e.g., an image) … Read more

Retrieving Android API version programmatically

As described in the Android documentation, the SDK level (integer) the phone is running is available in: android.os.Build.VERSION.SDK_INT The class corresponding to this int is in the android.os.Build.VERSION_CODES class. Code example: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP){ // Do something for lollipop and above versions } else{ // do something for phones running an SDK before lollipop … Read more