How can I customize the permission dialog in Android?

The short answer is: you can’t. As the Android documentation puts it: When your app calls requestPermissions(), the system shows a standard dialog box to the user. Your app cannot configure or alter that dialog box. If you need to provide any information or explanation to the user, you should do that before you call … Read more

Android notification setSound is not working

below code will help you: String CHANNEL_ID=”1234″; Uri soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + “://”+ getApplicationContext().getPackageName() + “/” + R.raw.mysound); NotificationManager mNotificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE); //For API 26+ you need to put some additional code like below: NotificationChannel mChannel; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { mChannel = new NotificationChannel(CHANNEL_ID, Utils.CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); mChannel.setLightColor(Color.GRAY); mChannel.enableLights(true); mChannel.setDescription(Utils.CHANNEL_SIREN_DESCRIPTION); AudioAttributes audioAttributes = new … Read more

Android: what to choose for requestcode values?

Documenting the findings for future reference: The following are code from android.support.v4.app.FragmentActivity /** * Modifies the standard behavior to allow results to be delivered to fragments. * This imposes a restriction that requestCode be <= 0xffff. */ @Override public void startActivityForResult(Intent intent, int requestCode) { if (requestCode != -1 && (requestCode&0xffff0000) != 0) { throw … Read more

Can you request permissions synchronously in Android Marshmallow (API 23)’s runtime permissions model?

As of Marshmallow, my understanding is that you can’t. I had to solve the same issue in my app. Here’s how I did it: Refactoring: Move every chunk of code that depends on permissions of some kind into a method of its own. More refactoring: Identify the trigger for each method (such as starting an … Read more

Crash casting AndroidKeyStoreRSAPrivateKey to RSAPrivateKey

I managed to get this working by removing the Provider from Cipher.getInstance and not casting to a RSAprivateKey. KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) entry; Cipher output = Cipher.getInstance(“RSA/ECB/PKCS1Padding”); output.init(Cipher.DECRYPT_MODE, privateKeyEntry.getPrivateKey()); I’m not 100% but I think the reason for this I believe is the change in marshmallow from OpenSSL to BoringSSL. https://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client Anyway, the above worked … Read more

SCAN_RESULTS_AVAILABLE_ACTION return empty list in Android 6.0

As of Android 6.0, permission behaviour has changed to runtime. To use a feature that requires a permission, one should check first if the permission is granted previously. Using checkSelfPermission(permissionString) method a result is returned, wither ther permission is PERMISSION_GRANTED or PERMISSION_DENIED. If permission isn’t granted or it is first time, a request for permission … Read more

App links intent filters in assetlinks.json not working on Android

For us it was Windows line endings! Testing with “https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain1:port&relation=delegate_permission/common.handle_all_urls” proved invaluable as it gave us an “Could not parse statement list (not valid JSON)” error which led us to the problem. TIP: It was good to use the ‘Save File’ button in the Android Studio App Links Assistant instead of copying and pasting as … Read more

How does storage access change on Android 6?

Let me answer Adoptable Storage Devices related questions: Suppose the user has chosen to use “Adoptable Storage Devices”, what does it mean for the various functions that retrieve the paths of the app’s files? For example : getFilesDir, getExternalFilesDir,… ? Would the oder of getExternalFilesDirs change because of it? When user choose to use SD … Read more

Bluetooth Low Energy startScan on Android 6.0 does not find devices

I struggled with the same issue. To fix it you have to enable “Location” (GPS) in the settings of the phone as well as request location permission in the app at runtime. Both need to be done for scanning to work properly. To request the location permission put the following in a dialog or the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)