Last active
December 17, 2018 18:18
-
-
Save nshimiye/388acfeac17ec379ab607a79a5ca88ee to your computer and use it in GitHub Desktop.
React native android module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.memorydebugger; | |
import com.facebook.react.bridge.NativeModule; | |
import com.facebook.react.bridge.ReactApplicationContext; | |
import com.facebook.react.bridge.ReactContext; | |
import com.facebook.react.bridge.ReactContextBaseJavaModule; | |
import com.facebook.react.bridge.ReactMethod; | |
import com.facebook.react.bridge.Promise; | |
import android.content.Context; | |
import android.widget.Toast; | |
import android.app.ActivityManager; | |
public class MDebuggerModule extends ReactContextBaseJavaModule { | |
ReactApplicationContext reactContext; | |
public MDebuggerModule(ReactApplicationContext reactContext) { | |
super(reactContext); | |
this.reactContext = reactContext; | |
} | |
@Override | |
public String getName() { | |
return "MDebugger"; | |
} | |
@ReactMethod | |
public void isLowMemory(Promise p) { | |
ActivityManager actMgr = (ActivityManager) this.reactContext.getSystemService(Context.ACTIVITY_SERVICE); | |
ActivityManager.MemoryInfo memInfo = new ActivityManager.MemoryInfo(); | |
actMgr.getMemoryInfo(memInfo); | |
p.resolve(memInfo.lowMemory); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment