Hello I am facing issue that Some devices not show run time permission.what would be the issue? I am facing on some devices and app crashes.but when I go to settings and allow permissions then it is fine
Asked
Active
Viewed 569 times
0
-
crash log + what are the devices? and how sure are you that its device issue & not code issue, and finally, if you talking about Xiomi devices, then you gonna have a nightmare. – Kosh Dec 07 '16 at 06:39
-
you also need to add this permissions to manifest...have you done this or do you just request at runtime? – Opiatefuchs Dec 07 '16 at 06:41
-
Post *error log* or *Logcat*. And make sure what @Opiatefuchs Sir is suggesting check and go through that part. – Jay Rathod Dec 07 '16 at 06:43
-
on nexus 5 it is working fine and many more.but my client have samsung s7,Lg g2 having 6.0 .it just crash. java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.BufferedReader.close()' on a null object reference 1at com.bugsense.trace.Utils.manageUid(Unknown Source) 2at com.bugsense.trace.BugSenseHandler$1.run(Unknown Source) 3at java.lang.Thread.run(Thread.java:818) – Usman R Dec 07 '16 at 07:43
-
if it is code issue then why it is running on some device haivng 6.0.1 @jay – Usman R Dec 07 '16 at 07:45
3 Answers
0
Best practice to handle run time permission is via RxPermission.
Try with RxPermission will solve you issue

Amit Bhati
- 1,405
- 12
- 20
-
on nexus 5 it is working fine and many more.but my clinet have samsung s7 having 6.0 – Usman R Dec 07 '16 at 07:03
0
String[] permissions = new String[]{
Manifest.permission.WRITE_SETTINGS,
Manifest.permission.SYSTEM_ALERT_WINDOW,
Manifest.permission.WAKE_LOCK,
Manifest.permission.INTERNET,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.BROADCAST_STICKY,
Manifest.permission.VIBRATE,
Manifest.permission.RECORD_AUDIO,
};
private boolean checkPermissions() {
int result;
List<String> listPermissionsNeeded = new ArrayList<>();
for (String p : permissions) {
result = ContextCompat.checkSelfPermission(getActivity(), p);
if (result != PackageManager.PERMISSION_GRANTED) {
listPermissionsNeeded.add(p);
}
}
if (!listPermissionsNeeded.isEmpty()) {
ActivityCompat.requestPermissions(root, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]), REQUEST_ID_MULTIPLE_PERMISSIONS);
return false;
}
return true;
}
@Override
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
if (requestCode == REQUEST_ID_MULTIPLE_PERMISSIONS) {
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
// selectImage();
// isPermission = true;
}
return;
}
}

Bipin Bharti
- 1,034
- 2
- 14
- 27
-
-
-
-
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.io.BufferedReader.close()' on a null object reference 1at com.bugsense.trace.Utils.manageUid(Unknown Source) 2at com.bugsense.trace.BugSenseHandler$1.run(Unknown Source) 3at java.lang.Thread.run(Thread.java:818) – Usman R Dec 07 '16 at 09:14
-
-
-
i will show you.but the point is that code is working on other apps.the same code – Usman R Dec 07 '16 at 12:12
-
0
You can set the Permissions without dialog at the first start of your App programmatically.
private void setPermission(string permission){
Process process = null;
try {
process = Runtime.getRuntime().exec("/system/bin/su -c pm grant " + [your package name] + " " + permission);
process.waitFor();
Log.d(TAG, "permission exec done " + process.exitValue());
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Now you can call it with:
setPermission("android.permission.SYSTEM_ALERT_WINDOW");
I'm not 100 % sure if you need sudo.

iMorphborg
- 31
- 4
-
I am facing this error with above code java.io.IOException: Error running exec(). Command: [/system/bin/su, -c, pm, grant, "package name", android.permission.ACCESS_FINE_LOCATION] Working Directory: null Environment: null – Usman R Dec 08 '16 at 18:38