android-permissions

What is the difference between shouldShowRequestPermissionRationale and requestPermissions?

点点圈 提交于 2019-12-03 06:52:26
I am building an app that requires user location. I am following the Android training documentation from here which says: shouldShowRequestPermissionRationale return the boolean indicating whether or not we should show UI with rationale for requesting a permission (dangerous permission, ACCESS_FINE_LOCATION) Now in this code (taken from the documentation itself) : if (ContextCompat.checkSelfPermission(thisActivity, Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { // Should we show an explanation? if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,

Get CPU usage of a device running Android 8 Oreo

别等时光非礼了梦想. 提交于 2019-12-03 06:15:29
I'm really confused. I have just noticed that starting from Android 8 all system calls like /proc/stat will be disabled. Ok, but what is work around to get CPU Usage in Android 8? No system calls at all. Is there some API that I'm not familiar with? I really hope that there is solution which I can't see now. No, all of /proc/stat has been disabled for non-System apps, as a side-channel. More information, with an official response from Google here: https://issuetracker.google.com/issues/37140047 来源: https://stackoverflow.com/questions/46182041/get-cpu-usage-of-a-device-running-android-8-oreo

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

Deadly 提交于 2019-12-03 06:14:32
问题 Say you have a method like this: public boolean saveFile (Url url, String content) { // save the file, this can be done a lot of different ways, but // basically the point is... return save_was_successful; } Throughout your app, if you want to save a file to external storage, you do something like... if (saveFile(external_storage_url, "this is a test")) { // yay, success! } else { // notify the user something was wrong or handle the error } This is a simplified example, so don't get on my

Duplicate permission request after orientation change

折月煮酒 提交于 2019-12-03 05:46:33
Because the Android SDK 23 gives users the possibility to deny apps access to certain functionalities I wanted to update one of my apps to request permissions as it is described in here: https://developer.android.com/preview/features/runtime-permissions.html . In one of the activities I embed a SupportMapFragment . To make it work you need to have the WRITE_EXTERNAL_STORAGE permission, so I request it when I start the activity which results in a creation of a permission request dialog. Now the problem is that when the dialog is still open and I rotate the device the activity will be restarted

Putting permissions to manifest of Android .aar library project

我的梦境 提交于 2019-12-03 02:55:16
I am developing an Android project which includes two modules where one is a library module for producing .aar files and another is a sample app utilising the produced .aar file. Thus, there are two AndroidManifest.xml files in this project. Say I am developing a Bluetooth library, so I put permissions for bluetooth in library's manifest file. By including this library .aar as dependency, can I omit the <uses-permission> tag in the app's manifest file? In other words, does Android app "merge" (may be not literally but semantically) its dependent .aar libraries' permissions? My experience

Revoked permission android.permission.CALL_PHONE

守給你的承諾、 提交于 2019-12-03 01:36:23
I'm trying to programmatically call to a number with following code: String number = ("tel:" + numTxt.getText()); Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse(number)); startActivity(intent); I've set the permission in the Manifest: <uses-permission android:name="android.permission.CALL_PHONE"/> I'm working with real device for testing and debugging, it is Nexus 5 with Android M, my compileSdkVersion is 23. I'm getting the following Security Exception: error: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxxx cmp=com.android

Android permission.INTERACT_ACROSS_USERS denial

Deadly 提交于 2019-12-03 01:18:55
I've a strange android permission denial, here is it: java.lang.SecurityException: Permission Denial: isUserRunning() from pid=1078, uid=10284 requires android.permission.INTERACT_ACROSS_USERS I haven't found anything about android.permission.INTERACT_ACROSS_USERS only android.permission.INTERACT_ACROSS_USERS_FULL Here is the full logcat: java.lang.SecurityException: Permission Denial: isUserRunning() from pid=25403, uid=10310 requires android.permission.INTERACT_ACROSS_USERS at android.os.Parcel.readException(Parcel.java:1693) at android.os.Parcel.readException(Parcel.java:1646) at android

How to get device's IMEI/ESN number with code programming But in android > 6

北城以北 提交于 2019-12-03 00:43:45
My Android version is Marshmallow 6.0 How to Find / Get imei number in android > 6 programmatically. Note : I added READ_PHONE_STATE permission inside AndroidManifest.xml file. <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission> And inside MainActivity TelephonyManager manager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); String deviceid = manager.getDeviceId(); //Device Id is IMEI number Log.d("msg", "Device id " + deviceid); My Android version is Marshmallow 6.0 Note : You need Runtime Permissions I added READ_PHONE_STATE permission

Android permissions: Perform task after user pressed “Allow”

爱⌒轻易说出口 提交于 2019-12-02 22:38:48
I would like to know if there is a way we can identify the event when the user has pressed "Allow" button for contact details access/ calendar access etc., I know there is a way to ask for permissions with the ActivityCompat.requestPermissions but is there a way to perform an action right after the user grants a permission? First Define the variable: public static int MY_PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION = 1; request permission using: if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Should we show

When should I use ACCESS_COARSE_LOCATION permission?

£可爱£侵袭症+ 提交于 2019-12-02 21:01:35
I am building an Android app that will track the user's geolocation and draw their route on a map. I am using the Google Play Services location API, as described here . It is intuitive that my application requires the ACCESS_FINE_LOCATION permission, which I put in the manifest: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> Do I also need the ACCESS_COARSE_LOCATION permission? What's the use case where I need the coarse location? Do I also need the ACCESS_COARSE_LOCATION permission? No. What's the use case where I need the coarse location? If you do not ask for