android : camera doesn’t open in marshmallow

So, I accomplished my task like as below: For Checking permission I created a separate class as below: public class MarshMallowPermission { public static final int RECORD_PERMISSION_REQUEST_CODE = 1; public static final int EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 2; public static final int CAMERA_PERMISSION_REQUEST_CODE = 3; Activity activity; public MarshMallowPermission(Activity activity) { this.activity = activity; } public boolean … Read more

How app can access files on USB OTG storages in Android 6.0 (API level 23) without root?

Since Android 6, according to the USB Media Support documentation, the Storage Access Framework seems to be the only available mecanism: In Android 6.0, any device that is not adopted is considered portable. […] Third-party apps must go through the Storage Access Framework to interact with files on portable storage; direct access is explicitly blocked … Read more

Provide custom text for Android M permission dialog

No, you can’t customize the text of the dialog, but you can provide an explanation before request the permission. Quoting from developer.android.com: Request Permissions If your app needs a dangerous permission that was listed in the app manifest, it must ask the user to grant the permission. Android provides several methods you can use to … Read more

Android 6: cannot share files anymore?

I solved it by implementing a FileProvider, as suggested by @CommonsWare You first need to configure a FileProvider: first, add the <provider> to your file manifest XML <provider android:name=”android.support.v4.content.FileProvider” android:authorities=”com.myfileprovider” android:exported=”false” android:grantUriPermissions=”true”> <meta-data android:name=”android.support.FILE_PROVIDER_PATHS” android:resource=”@xml/file_provider_paths” /> </provider> second, define your file paths in a separate XML file, I called it “file_provider_paths.xml“ <paths xmlns:android=”http://schemas.android.com/apk/res/android”> <external-path name=”share” … 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

Request runtime permissions from v4.Fragment and have callback go to Fragment?

Adding this to the parent activity works for me: @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); List<Fragment> fragments = getSupportFragmentManager().getFragments(); if (fragments != null) { for (Fragment fragment : fragments) { fragment.onRequestPermissionsResult(requestCode, permissions, grantResults); } } } Source: https://code.google.com/p/android/issues/detail?id=189121#c5

How to change the status bar notification icons’ color/tint in android (marshmallow and above 23+)?

For the status bar icons’ to have a dark tint instead of the default white, add the following tag in your styles.xml (or more precisely in values-v23/styles.xml) file: <item name=”android:windowLightStatusBar” tools:targetApi=”23″>true</item> You can also change the flag at runtime by setting it to any View: View yourView = findViewById(R.id.your_view); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if … Read more