Today I came across the porting of a code to make it compatible for Android 7, so nougat, from the previous version. During this phase I discovered that from the SDK 25 onwards there is no longer the possibility to list via the listFiles of /proc.

This happened for security reasons narrowing the range of action that differentiates Android from iOS. (not of safety is well understood) The code that you glue is the relative one before the SDK 25 version. It remains valid from versions 25 onwards but is restricted to the reading permissions of the user running the application, so it will not list all the processes.

Alternatively, we always talk about devices with root, you can create a small script in sh:

sudo -c 'pidof processname'

For example, save it in the folder files of our app giving it the correct permissions via adb and then retrieve it via getRuntime().exec().I don't know if there are other valid and functional methods in case you comment to me suggesting?

Thank you all!

This happened for security reasons narrowing the range of action that differentiates Android from iOS. (not of safety is well understood) The code that you glue is the relative one before the SDK 25 versio