• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Create object for ActivityManager

saranya

Lurker
Oct 17, 2008
9
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
 
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

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.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones