Android Question /proc/stat (Permission denied) - MSOS Library

Lucas Eduardo

Active Member
Licensed User
i was testing this lib https://www.b4x.com/android/forum/t...d-osstats-and-getforegroundapp.34954/#content
on Android less than 8 is ok, but when I tested it on Android 8 I got this error
in line
B4X:
xOSStats.StartStats

B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
main_activity_resume (java line: 678)
java.io.FileNotFoundException: /proc/stat (Permission denied)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:200)
    at java.io.FileInputStream.<init>(FileInputStream.java:150)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:214)
    at anywheresoftware.b4a.objects.streams.File.ReadString(File.java:276)
    at b4a.example.osstats._readcpu(osstats.java:267)
    at b4a.example.osstats._startstats(osstats.java:325)
    at msos.sample2.main._activity_resume(main.java:678)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at msos.sample2.main.afterFirstLayout(main.java:114)
    at msos.sample2.main.access$000(main.java:21)
    at msos.sample2.main$WaitForLayout.run(main.java:86)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:7000)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)

i'm asking the permission PERMISSION_WRITE_EXTERNAL_STORAGE and to user allow me to use the usage stats PACKAGE_USAGE_STATS, but i still getting the error

What permission could i ask to user?
 

DonManfred

Expert
Licensed User
Longtime User
it depends on android.permission.GET_TASKS which is no longer available since lollipop
 
Upvote 0
Top