Create object for ActivityManager


Last Updated:

  1. saranya

    saranya Member This Topic's Starter

    Joined:
    Oct 17, 2008
    Messages:
    9
    Likes Received:
    1
    I am trying to get memorystatus.For that i need to use method getMemoryInfo(ActvityManager.MemoryInfo).I can access it by using ActivityManager class only.But i can't make it out.Please help me to create object for activitymanager.And Can i get Total memory in emulator ?Or we can get it in mobile testing only.
    Thanks in advance
    saran
     

    Advertisement
  2. androidhelp

    androidhelp New Member

    Joined:
    May 6, 2010
    Messages:
    1
    Likes Received:
    0
    Hi,
    u can try following code:
    ActivityManager actvityManager = (ActivityManager) this.getSystemService( ACTIVITY_SERVICE );
    ActivityManager.MemoryInfo mInfo = new ActivityManager.MemoryInfo ();
    actvityManager.getMemoryInfo( mInfo );
    // Print to log and read in DDMS
    Log.i( "TAG", " minfo.availMem " + mInfo.availMem );
    Log.i( "TAG", " minfo.lowMemory " + mInfo.lowMemory );
    Log.i( "TAG", " minfo.threshold " + mInfo.threshold );

    It worked for me.
    Hope it helps u.
     

Share This Page

Loading...