Is there any way to run terminal commands on my application and then access the data on my UI? Specifically top
.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
Okay this is what exactly worked for me just in case anyone needs it in the future... :)
Surround in try and catch
We, can execute commands as follow, i was succesfull in doing this....! try like this, here we need to specify the complete path of command. to get the complete path of commmand, at ur terminal (android) type
*$ which ls
/system/bin*
Check out Log Collector as an example. Here is the relevant file.
The key is here:
it also depends on what you are running in the terminal... if you are running "cat" on a file you can also do it like this.
EDIT: There is a perfect example for you in the android labs project called netmeter. There is a class called Top.java that actually does exactly what you want and it is used in TaskList.java to be displayed. http://code.google.com/p/android-labs/source/browse/#svn/trunk/NetMeter/src/com/google/android/netmeter