android-6.0-marshmallow

Permission changed callback in Android 6.0

隐身守侯 提交于 2019-12-06 03:17:43
问题 I wonder if there is some way to being notified when user changes permission in app settings on Android 6.0. I was looking for this answer with no luck. Do you know if it is possible with broadcast receiver and some specific Intent? Or maybe there is some hack to achieve this? 回答1: according to this answer, there is no any broadcast/event that you can intercept when permission revoked from the settings screen by the user. but the "good" news, in assumption that it's your concern - your

What is the use case for ContextCompat.checkSelfPermission?

此生再无相见时 提交于 2019-12-06 03:10:47
问题 Currently I have the following method to check for runtime permission in AppCompatActivity for Marshmallow : if(Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { boolean hasPermission = checkSelfPermission(Manifest.permission.XX) == PackageManager.PERMISSION_GRANTED; if(!hasPermission) { if(shouldShowRequestPermissionRationale(Manifest.permission.XX)) { // explain reason for permission, try again } else { // user deny with "don't show again" } } } So far I find it works reasonably

Android M - GoogleAccountCredential setSelectedAccount doesn't work - name must not be null

断了今生、忘了曾经 提交于 2019-12-06 02:12:32
问题 On the Android M-Preview GoogleAccountCredential.setSelectedAccount doesn't seem to work. When debugging, I noticed that after calling that method, the selectedAccount and accountName fields of the object are still null. While debugging you can see that my variable accountName is not empty or null, I call the .setSelectedAccountName() , but as you can see in the debug window, the field in the GoogleAccountCredential is still null. I think this can be related to some permissions? On my

Getting an error on recreate() inside onOptionsItemSelected() in API 23 / Marshmallow

左心房为你撑大大i 提交于 2019-12-06 01:43:14
问题 I am trying to make my App, which works perfectly on API<23 devices, to work on an API 23 device. It crash in the following senario. The user changes settings via options menu . If they tap slowly on the menu option (so there is time to see the option being highlighted), everything is fine, but if they tap briefly, the App crashes. I know it's a quit strange behaviour and I have spend some time trying to understand what fires the error. The error occurs after recreate() which is in

Android M : How to open Permission Dialog even if user selects Never Ask Again ?

浪尽此生 提交于 2019-12-05 18:42:11
If not what is the workaround to prompt user to setting page or any other solution ? Deepak Goyal You can't open the request permission dialog if user selects Never Ask Again. But you can show the information to user. @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case REQUEST_CODE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Toast.makeText(MainActivity.this, "Permission Granted", Toast.LENGTH

getAccountsByType does not return anything in marshmallow

对着背影说爱祢 提交于 2019-12-05 17:41:55
问题 Now this is odd... Using AccountManager.newChooseAccountIntent(null, null, new String[] {"com.google"}, null, null, null, null); does give me a list of accounts. But using AccountManager.get(context).getAccountsByType("com.google") returns 0 accounts. The problem only happens in marshmallow. <uses-permission android:name="android.permission.GET_ACCOUNTS" /> still exists in the manifest. Any ideas...? UPDATE: Turns out, must ask permission for GET_ACCOUNTS, even though docs say otherwise...

Android Adoptable Storage - get free Space

不打扰是莪最后的温柔 提交于 2019-12-05 16:46:15
I have a App that uses 3 kinds of storage: The internal storage, a external SD and if Version >= 6.0 a SD which is formatted as internal . I get the external SD path by using getExternalFilesDirs() , the internal Storage by getFilesDir() and the adopted (=internal) SD path by Environment.getExternalStorageDirectory() . Now, if I want to get the free Space, something like this: StatFs statFs = new StatFs(storageDir); long blocks = statFs.getAvailableBlocks(); return Formatter.formatFileSize(this, blocks * statFs.getBlockSize()); works for internal storage and external SD, but for adopted SD it

Which permission do we need at runtime in android 6.0

落爺英雄遲暮 提交于 2019-12-05 13:52:04
I have an android code which can work well on Android 5.0 version. My AndroidManifest.xml is <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BROADCAST_STICKY" /> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> <uses-permission android:name="android.permission.WAKE_LOCK" /> However, my

How come a GCM permission isn't granted on Android 6?

感情迁移 提交于 2019-12-05 11:36:20
Background I'm trying to investigate what an app at the office needs to change about its permissions, in order to support Android 6 nicely. The problem I've found which permission needs confirmation and which isn't, except for one : <uses-permission android:name=".permission.C2D_MESSAGE"/> It seems that this permission isn't mentioned anywhere that I look for, as one that's not granted automatically and yet I can't find where the user can enable it as a confirmation. What I tried In order to find which permissions are granted by default and which aren't , I just called this code: private void

Enable Mock Locations in Android Marshmallow

江枫思渺然 提交于 2019-12-05 08:18:28
I cannot get mock locations to work in Android Marshmallow. I have installed app in Android 6.0 . Now, When I want to set mock location for this app by following option. Setting >> Developer Option >> Select Mock location app I can not see any Application to select. Has anyone had success enabling mock locations under Marshmallow? If you use the Mock location permission: <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> Then you will be able to select your app by Setting >> Developer Option >> Select Mock location app I was facing the same problem. Even though my app's