android-permissions

onRequestPermissionsResult called in HomeActivity but not in Fragment

不羁的心 提交于 2020-01-05 05:25:22
问题 In a fragment I call requestPermissions public class FgDialogFragment extends DialogFragment { requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE},22); In the HomeActivity. java I wrote this code which is working fine @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { Log.i("info", "Result recieved"); } but I want to get onRequestPermissionsResult on the FgDialogFragment class. I tried this but it's not

How to read call log history of a device in android in 6.0

[亡魂溺海] 提交于 2020-01-05 04:18:13
问题 My main aim of the app is to read the call history of the device and show it to the user using recyclerview and cardview. But When i run on marshmallow device app getting force close. Here is the code that i have used to read call history and the error that i got, when i run on 6.0 My MainActivity look like: public class MainActivity extends AppCompatActivity implements Callbacks { ArrayList<CallLogItem> mItems = new ArrayList<>(); private RecyclerView mRecyclerView; private RecyclerView

How to handle onPermissionResult for ACCESS_FINE_LOCATION properly?

∥☆過路亽.° 提交于 2020-01-04 10:21:50
问题 I'm writing some sort of hello world program for Google Location Services. I already coded most of the stuff; here's the onConnected method: public void onConnected(Bundle bundle) { // Construct the Location Request mLocationRequest = new LocationRequest(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(30000); // Check if permission granted if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=

How to handle onPermissionResult for ACCESS_FINE_LOCATION properly?

大憨熊 提交于 2020-01-04 10:20:14
问题 I'm writing some sort of hello world program for Google Location Services. I already coded most of the stuff; here's the onConnected method: public void onConnected(Bundle bundle) { // Construct the Location Request mLocationRequest = new LocationRequest(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(30000); // Check if permission granted if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=

File.listFiles returns null when it shouldn't

自古美人都是妖i 提交于 2020-01-04 09:09:09
问题 I am trying to get list of files existing in the Phone Pictures folder (internal storage, no SDCard inserted) using this: File file = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File[] files = file.listFiles(); but files value is always being null. I also add this to AndroidManifest.xml <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> Any ideas will be much appreciated, thanks in advance. 回答1: If you are targeting Android SDK >=23

Can a service request for permission in Android M?

亡梦爱人 提交于 2020-01-04 01:59:08
问题 I figured that in M requestPermissions() can only be called by an Activity class. I have an app that has no UI screen. It runs as a background service. Does this mean that I have to put a spinner screen if checkSelfPermissions returns denied? 回答1: I have an app that has no UI screen. Then it will never run, unless it is preinstalled on an Android device or custom ROM, or it is a plugin to some other app. Otherwise, your app will remain in the stopped state forever. Pretty much every app

How to access /data folder of another application through your application?

五迷三道 提交于 2020-01-03 17:19:28
问题 there is a text file that an application produces, I would like to take that file and read it as strings in my application. How can I achieve that, any help would be grateful. Both applications are my applications so I can get the permissions. Thank you! 回答1: This is possible using the standard android-storage, where all the user's files are stored too: All you need to do is to access the same file and the same path in both applications, so e.g.: String fileName = Environment

Read permission of installed Application in android phone?

二次信任 提交于 2020-01-03 07:16:06
问题 I want to read permission of other applications installed in my android mobile using programming. I think Android Cleaner read permission of other apps and display details like I want get detail like this Image. In this it's give details of Ad Network How i get details like this app in my app? If this app not Read Permission then How it's do it? 回答1: Well you can scrape the playstore app page for a given app and get the permissions it needs :) Well that's just off the top of my head. On a

Write to external storage on Android 7

末鹿安然 提交于 2020-01-03 05:18:11
问题 I want to write to the external storage in my Android app, but I don't seem to get the permissions right. The App runs on Android 7, so I request the permissions on runtime like this: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); if (permission != PackageManager.PERMISSION_GRANTED) { // We

Avoid Screen Overlay Detected for service that uses SYSTEM_ALERT_WINDOW

僤鯓⒐⒋嵵緔 提交于 2020-01-03 03:21:16
问题 My app main usage is overlay, the overlay is running from a service. Android Security add the nice "Screen Overlay Detected" I want to avoid "Screen Overlay Detected" when user tries to change permissions. so... I've add an AccessiblityService that detects: if ( event.getPackageName().equals("com.google.android.packageinstaller") ){ stopService(myServiceIntent); } However, even now I see this message popping. (when my service is stopped...). I saw Twilight does it without problem. What am I