Guest User

Untitled

a guest
Jun 25th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo();
  2. ActivityManager activityManager = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
  3. activityManager.getMemoryInfo(memInfo);
  4. String TotalRam = String.valueOf(memInfo.totalMem);
  5. int totaLram = Integer.parseInt(TotalRam);
  6. String freeRam = String.valueOf(memInfo.availMem);
  7. int freRAm = Integer.parseInt(freeRam);
  8.  
  9. Handler handler = new Handler(Looper.getMainLooper());
  10. Runnable myTask = new Runnable() {
  11. void run() {
  12. // do something ...
  13.  
  14. handler.postDelayed(myTask, 100 /* milliseconds */);
  15. }
  16. };
  17.  
  18. void onStart() {
  19. super.onStart();
  20.  
  21. handler.post(myTask);
  22. }
  23.  
  24. void onStop() {
  25. super.onStop();
  26.  
  27. handler.removeCallbacks(myTask);
  28. }
Add Comment
Please, Sign In to add comment