android-permissions

Android UsageStatsManager: Get a list of currently running apps on phone

◇◆丶佛笑我妖孽 提交于 2019-12-06 04:11:34
I am trying to get a list of currently running apps on my phone. Here is the code I am using: if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { UsageStatsManager usm = (UsageStatsManager)this.getSystemService(Context.USAGE_STATS_SERVICE); long time = System.currentTimeMillis(); List<UsageStats> appList = usm.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, time - 10000*10000, time); if (appList != null && appList.size() == 0) { Log.d("Executed app", "######### NO APP FOUND ##########" ); } if (appList != null && appList.size() > 0) { SortedMap<Long, UsageStats

App crashes with SecurityException on Android M [duplicate]

≯℡__Kan透↙ 提交于 2019-12-06 03:36:07
This question already has answers here : Android 6.0 Permission Error (5 answers) Closed 4 years ago . Yesterday I set upped target and compile sdk to 23 API level. When I launched the app on Nexus 9 with Preview Android M (MPA441) the app crashes with following SecurityException : FATAL EXCEPTION: main Process: com.grouplogic.mobilecho, PID: 22554 java.lang.RuntimeException: Unable to create application com.mypackage.MyApplication: java.lang.SecurityException: getDeviceId: Neither user 10098 nor current process has android.permission.READ_PHONE_STATE. at android.app.ActivityThread

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

How to remove a permission added because of Google Fitness API 7.5.0

百般思念 提交于 2019-12-06 02:47:56
问题 After updating my play-services-fitness api from 7.0.0 to 7.5.0 I noticed that when I go to upload a new build to the PlayStore it tells me that I am adding a new permission and 2 new features. I did not do this! What the heck. 回答1: After doing some research to pin down the culprit it was in fact play-services-fitness:7.5.0 that was to blame. By including that in your project ( compile 'com.google.android.gms:play-services-fitness:7.5.0' ) and compiling it will inject the <uses-permission

Draw Overlay permission for apps installed from Play Store

南笙酒味 提交于 2019-12-06 02:14:02
问题 Here is a well-known Q/A about draw overlay permission issue. I observed same behavior on my previous apps also, i.e. it was automatically granted when the app is installed from Play Store. In my recent app, however, I observed that that permission is not granted even if it is installed from Play Store. At first, I thought that this might be a specific problem for our test devices. However, I wanted to be sure about it by tracking the number of such lack-of-permission situations in the wild

when I add android.permission.UPDATE_DEVICE_STATS to my app.error occur

岁酱吖の 提交于 2019-12-06 01:39:37
I developed an app which needs to get the android.permission.UPDATE_DEVICE_STATS permission. However, when I add this permission to my app's AndroidMainfest.xml file, I get this error: "Permission is only granted to system apps" What can I do to change my app to system app? Are there any other ways to solve this problem? Timmetje Most importantly to know: A system app can only be run by people who have rooted their device. Meaning you can't test and run your own application if you don't have a rooted device. You can declare your app to run as a system app by setting the sharedUserId as follows

Android O can't receive broadcast Intent.ACTION_NEW_OUTGOING_CALL

ぐ巨炮叔叔 提交于 2019-12-06 01:37:12
In my application, I can receive android.intent.action.PHONE_STATE but can't receive Intent.ACTION_NEW_OUTGOING_CALL on android O . If I use android N or android M everything work fine. I have register first broadcast in AndroidManifest file and second in foreground service , but none of them can receive Intent.ACTION_NEW_OUTGOING_CALL , only can receive android.intent.action.PHONE_STATE . If anyone know how to fix it, please post your answer, thanks in advance. Arnav M. But I am still confused, because my phone not ask me to give the permission but work fine. Maybe a bug or feature of android

How to ask for multiple permissions one after another?

余生颓废 提交于 2019-12-05 22:29:47
My app requires to access CAMERA and WRITE_EXTERNAL_STORAGE permissions. Once my app loads I want to ask user to allow both of these permissions one after another. I have this code: if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 2); } if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission

Adding new uses-policies to existing device administrator on Android

夙愿已清 提交于 2019-12-05 21:32:36
I have a device admin app that uses the following device-admin.xml <device-admin xmlns:android="http://schemas.android.com/apk/res/android"> <uses-policies> <watch-login /> <reset-password /> <force-lock /> <wipe-data /> </uses-policies> </device-admin> Some users has already activated the device admin permissions. Now, in an update of the app, I want to add a new uses-policy <limit-password /> I am wondering how to detect that new use policies have been added programmatically so that we push the reactivation of the device admin permissions? AFAIK the only way is read your device-admin.xml

When to use READ_GSERVICES permission?

纵饮孤独 提交于 2019-12-05 18:01:45
问题 I have an application which uses Google Play Services for GCM and ads. My last update added an in-app billing and I received a crash report for : java.lang.SecurityException: attempting to read gservices without permission: Neither user 10237 nor current process has com.google.android.providers.gsf.permission.READ_GSERVICES. I never had this problem before, nor did I when I tested my application with IAP. It only happens on one device (Xperia Z, surely the same user). When I search for this