IllegalArgumentException: column ‘_data’ does not exist

As per given answer by CommonsWare, the solution code is : public static String getFilePathFromURI(Context context, Uri contentUri) { //copy file and send new file path String fileName = getFileName(contentUri); if (!TextUtils.isEmpty(fileName)) { File copyFile = new File(TEMP_DIR_PATH + File.separator + fileName); copy(context, contentUri, copyFile); return copyFile.getAbsolutePath(); } return null; } public static String getFileName(Uri … Read more

Missing buttons on AlertDialog | Android 7.0 (Nexus 5x)

Indeed it seems that AlertDialog theme needs to be defined. An alternative approach to above would be to define AlertDialog theme in Application theme: <style name=”AppTheme” parent=”Theme.AppCompat.Light.NoActionBar”> <!– … other AppTheme items … –> <item name=”android:alertDialogTheme”>@style/AlertDialogTheme</item> </style> <style name=”AlertDialogTheme” parent=”Theme.AppCompat.Light.Dialog.Alert”> <item name=”colorPrimary”>@color/colorPrimary</item> <item name=”colorPrimaryDark”>@color/colorPrimaryDark</item> <item name=”colorAccent”>@color/colorAccent</item> </style> Then it is enough create AlertDialog.Builder only with … Read more

Android PackageStats gives negative Values

just tried on API 23/24 and can just instance it. these external* properties might refer to the SD card. PackageStats stats = new PackageStats(context.getPackageName()); long codeSize = stats.codeSize + stats.externalCodeSize; long dataSize = stats.dataSize + stats.externalDataSize; long cacheSize = stats.cacheSize + stats.externalCacheSize; long appSize = codeSize + dataSize + cacheSize;

‘App is scanning too frequently’ with ScanSettings.SCAN_MODE_OPPORTUNISTIC

Android 7 prevents scan start-stops more than 5 times in 30 seconds. The bad side is, it doesn’t return an error, instead just prints a log. The app thinks the scan is started but it’s not actually started back at the ble stack. Also it converts long running scans to opportunistic scan with an intent … Read more

Detect CONNECTIVITY CHANGE in Android 7 and above when app is killed/in background

Nougat and Above: We have to use JobScheduler and JobService for Connection Changes. All I can divide this into three steps. Register JobScheduler inside activity. Also, Start JobService( Service to handle callbacks from the JobScheduler. Requests scheduled with the JobScheduler ultimately land on this service’s “onStartJob” method.) public class NetworkConnectionActivity extends AppCompatActivity { @Override protected … Read more

Job Scheduler not running on Android N

In Android Nougat the setPeriodic(long intervalMillis) method call makes use of setPeriodic (long intervalMillis, long flexMillis) to schedule periodic jobs. As per the documentation: JobInfo.Builder setPeriodic (long intervalMillis, long flexMillis) Specify that this job should recur with the provided interval and flex. The job can execute at any time in a window of flex length … Read more