android-permissions

How do I show permissions rationale for multiple permissions request?

不羁的心 提交于 2019-12-09 06:41:26
I am working with Android API 25 and need to make permissions requests in the app. There are a ton of code samples on how to make a request as well as how to show the rationale. This link here shows a simple methodology as do these: Android M Request Multiple permission at a single time , Android M request permission non activity The problem I am having is I am requesting multiple permissions at once (Location, Write storage access, and Contacts) and the ActivityCompatApi23.shouldShowRequestPermissionRationale source code only takes in a String for a single permission and not an array for

Android 6.0.1 couldn't enable wifi hotspot programmatically

非 Y 不嫁゛ 提交于 2019-12-09 05:46:46
问题 When I tried to enable wifi tethering from the following code it throws the exception java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com..... .... not granted this permission: android.permission.WRITE_SETTINGS But this works fine in android 6.0 and below versions. And also tried with giving android.permission.WRITE_SETTINGS too. Is there any limitation in accessing wifiAP in android 6.1? Follow I attached the code sample that I used to enable

How to avoid writing duplicate boilerplate code for requesting permissions?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-09 04:30:35
问题 I'm updating my app to be Android 6-compatible. The permission model is not very complex in theory, but now I'm in the process of implementing it and I find myself writing the same ugly boilerplate code in every one of my activities that require permissions. For every permission I need, there is a if (ActivityCompat.checkSelfPermission(this, Manifest.permission.PERMISSION) != PackageManager.PERMISSION_GRANTED) { } else { } and then in the onRequestPermissionsResult I have to check/filter the

Android 6.0 (Marshmallow) READ_CONTACTS permission allows to read Contact's name when permission is denied

寵の児 提交于 2019-12-09 03:09:01
问题 I want to check how new permission model works so in app's settings I disable Contacts . Then I go to app and try to read Contacts and ... it kinda works: try { Uri result = data.getData(); int contentIdx; cursor = getContentResolver().query(result, null, null, null, null); contentIdx = cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER); if(cursor.moveToFirst()) { content = cursor.getInt(contentIdx); } if(content > 0) { contentIdx = cursor.getColumnIndex(ContactsContract

Android permissions GET_ACCOUNTS and USE_CREDENTIALS show up automatically

自作多情 提交于 2019-12-08 17:45:12
问题 It has been quite a few months since I had time to work on my app. And today I downloaded latest Android Studio and SDK, I found a problem after I built the app. My AndroidManifest file does NOT require any permissions on GET_ACCOUNTS or USE_CREDENTIALS, however they are shown as new added permissions when I tried to upload the app in Google Play store. I did use Google Play Games service in the game, but it was not like this before I did this update. Does anybody know why? I Googled a while

Is the request for internet persmission required at runtime (Android)?

你说的曾经没有我的故事 提交于 2019-12-08 17:30:35
问题 For Android, it is required that we ask permissions at runtime to make sure users understand better why en when permissions are needed. I know this is true for permissions like WRITE_CALENDAR and ACCESS_FINE_LOCATION but it seems it's not required for INTERNET. Not strange because almost all apps use internet. Is it safe to say that I only need to declare it in the manifest? <uses-permission android:name="android.permission.INTERNET" /> Or should I always check it at runtime? 回答1: No, you

Android revoke permission at start of each test

跟風遠走 提交于 2019-12-08 15:00:56
问题 I'm using Espresso and UIAutomator to write my test cases. I'm testing external storage permissions when it's denied and when it's allowed. I have different test cases which all require the permission to be revoked at the start of the test case. However, some of the test cases should and do result in the permission being granted, so I need to revoke the permission when the next test is being executed. I have searched around and the closest thing I came across is using the pm manager to

Ask for location permission during runtime in Android

别说谁变了你拦得住时间么 提交于 2019-12-08 14:01:53
问题 I have a very simple app which takes location data from Google's fused location provider API and displays it. Now, for Android M+, I want to ask for location permission during run-time. Below is some relevant code from my MainActivity.java file: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if(checkAndRequestPermissions()) { // carry on the normal flow, as the case of permissions granted.

java.io.FileNotFoundException: No such file or directory Error

不想你离开。 提交于 2019-12-08 13:02:01
问题 I am downloading images to smartphone. For older versions not problem my code is working but for Oreo it is not working. I tried this code in Emulator. I implemented a function to save image to external storage. private void saveImageToExternalStorage(Bitmap finalBitmap,String name) { String root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString(); File myDir = new File(root + "/xx"); myDir.mkdirs(); String fname = name + ".jpg"; File file = new File

Can't delete file in Android

雨燕双飞 提交于 2019-12-08 11:00:12
问题 I wish delete music file stored on my phone (has no SD card) in Music folder. I have file path and File.exists() said true. Next, File.delete() also said true, but file stay in its place. But! After "deletion" I can no longer play this file, edit name and also can't copy it. But I can delete it manually. I've set android.permission.WRITE_EXTERNAL_STORAGE . OS 4.4.4 GPE Where is my mistake? Any suggestions, thanks. File file = new File(Path); if (file.exists()){ file.setWritable(true, false);