Methods Summary |
---|
private static java.lang.String | getAbsolutePath(java.io.File file)
return (file != null) ? file.getAbsolutePath() : null;
|
void | hideIme(int mode)
mIMM.hideSoftInputFromWindow(mNativeContentView.getWindowToken(), mode);
|
private native long | loadNativeCode(java.lang.String path, java.lang.String funcname, android.os.MessageQueue queue, java.lang.String internalDataPath, java.lang.String obbPath, java.lang.String externalDataPath, int sdkVersion, android.content.res.AssetManager assetMgr, byte[] savedState)
|
public void | onConfigurationChanged(android.content.res.Configuration newConfig)
super.onConfigurationChanged(newConfig);
if (!mDestroyed) {
onConfigurationChangedNative(mNativeHandle);
}
|
private native void | onConfigurationChangedNative(long handle)
|
private native void | onContentRectChangedNative(long handle, int x, int y, int w, int h)
|
protected void | onCreate(android.os.Bundle savedInstanceState)
String libname = "main";
String funcname = "ANativeActivity_onCreate";
ActivityInfo ai;
mIMM = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
getWindow().takeSurface(this);
getWindow().takeInputQueue(this);
getWindow().setFormat(PixelFormat.RGB_565);
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
mNativeContentView = new NativeContentView(this);
mNativeContentView.mActivity = this;
setContentView(mNativeContentView);
mNativeContentView.requestFocus();
mNativeContentView.getViewTreeObserver().addOnGlobalLayoutListener(this);
try {
ai = getPackageManager().getActivityInfo(
getIntent().getComponent(), PackageManager.GET_META_DATA);
if (ai.metaData != null) {
String ln = ai.metaData.getString(META_DATA_LIB_NAME);
if (ln != null) libname = ln;
ln = ai.metaData.getString(META_DATA_FUNC_NAME);
if (ln != null) funcname = ln;
}
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException("Error getting activity info", e);
}
String path = null;
File libraryFile = new File(ai.applicationInfo.nativeLibraryDir,
System.mapLibraryName(libname));
if (libraryFile.exists()) {
path = libraryFile.getPath();
}
if (path == null) {
throw new IllegalArgumentException("Unable to find native library: " + libname);
}
byte[] nativeSavedState = savedInstanceState != null
? savedInstanceState.getByteArray(KEY_NATIVE_SAVED_STATE) : null;
mNativeHandle = loadNativeCode(path, funcname, Looper.myQueue(),
getAbsolutePath(getFilesDir()), getAbsolutePath(getObbDir()),
getAbsolutePath(getExternalFilesDir(null)),
Build.VERSION.SDK_INT, getAssets(), nativeSavedState);
if (mNativeHandle == 0) {
throw new IllegalArgumentException("Unable to load native library: " + path);
}
super.onCreate(savedInstanceState);
|
protected void | onDestroy()
mDestroyed = true;
if (mCurSurfaceHolder != null) {
onSurfaceDestroyedNative(mNativeHandle);
mCurSurfaceHolder = null;
}
if (mCurInputQueue != null) {
onInputQueueDestroyedNative(mNativeHandle, mCurInputQueue.getNativePtr());
mCurInputQueue = null;
}
unloadNativeCode(mNativeHandle);
super.onDestroy();
|
public void | onGlobalLayout()
mNativeContentView.getLocationInWindow(mLocation);
int w = mNativeContentView.getWidth();
int h = mNativeContentView.getHeight();
if (mLocation[0] != mLastContentX || mLocation[1] != mLastContentY
|| w != mLastContentWidth || h != mLastContentHeight) {
mLastContentX = mLocation[0];
mLastContentY = mLocation[1];
mLastContentWidth = w;
mLastContentHeight = h;
if (!mDestroyed) {
onContentRectChangedNative(mNativeHandle, mLastContentX,
mLastContentY, mLastContentWidth, mLastContentHeight);
}
}
|
public void | onInputQueueCreated(android.view.InputQueue queue)
if (!mDestroyed) {
mCurInputQueue = queue;
onInputQueueCreatedNative(mNativeHandle, queue.getNativePtr());
}
|
private native void | onInputQueueCreatedNative(long handle, long queuePtr)
|
public void | onInputQueueDestroyed(android.view.InputQueue queue)
if (!mDestroyed) {
onInputQueueDestroyedNative(mNativeHandle, queue.getNativePtr());
mCurInputQueue = null;
}
|
private native void | onInputQueueDestroyedNative(long handle, long queuePtr)
|
public void | onLowMemory()
super.onLowMemory();
if (!mDestroyed) {
onLowMemoryNative(mNativeHandle);
}
|
private native void | onLowMemoryNative(long handle)
|
protected void | onPause()
super.onPause();
onPauseNative(mNativeHandle);
|
private native void | onPauseNative(long handle)
|
protected void | onResume()
super.onResume();
onResumeNative(mNativeHandle);
|
private native void | onResumeNative(long handle)
|
protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
byte[] state = onSaveInstanceStateNative(mNativeHandle);
if (state != null) {
outState.putByteArray(KEY_NATIVE_SAVED_STATE, state);
}
|
private native byte[] | onSaveInstanceStateNative(long handle)
|
protected void | onStart()
super.onStart();
onStartNative(mNativeHandle);
|
private native void | onStartNative(long handle)
|
protected void | onStop()
super.onStop();
onStopNative(mNativeHandle);
|
private native void | onStopNative(long handle)
|
private native void | onSurfaceChangedNative(long handle, android.view.Surface surface, int format, int width, int height)
|
private native void | onSurfaceCreatedNative(long handle, android.view.Surface surface)
|
private native void | onSurfaceDestroyedNative(long handle)
|
private native void | onSurfaceRedrawNeededNative(long handle, android.view.Surface surface)
|
public void | onWindowFocusChanged(boolean hasFocus)
super.onWindowFocusChanged(hasFocus);
if (!mDestroyed) {
onWindowFocusChangedNative(mNativeHandle, hasFocus);
}
|
private native void | onWindowFocusChangedNative(long handle, boolean focused)
|
void | setWindowFlags(int flags, int mask)
getWindow().setFlags(flags, mask);
|
void | setWindowFormat(int format)
getWindow().setFormat(format);
|
void | showIme(int mode)
mIMM.showSoftInput(mNativeContentView, mode);
|
public void | surfaceChanged(android.view.SurfaceHolder holder, int format, int width, int height)
if (!mDestroyed) {
mCurSurfaceHolder = holder;
onSurfaceChangedNative(mNativeHandle, holder.getSurface(), format, width, height);
}
|
public void | surfaceCreated(android.view.SurfaceHolder holder)
if (!mDestroyed) {
mCurSurfaceHolder = holder;
onSurfaceCreatedNative(mNativeHandle, holder.getSurface());
}
|
public void | surfaceDestroyed(android.view.SurfaceHolder holder)
mCurSurfaceHolder = null;
if (!mDestroyed) {
onSurfaceDestroyedNative(mNativeHandle);
}
|
public void | surfaceRedrawNeeded(android.view.SurfaceHolder holder)
if (!mDestroyed) {
mCurSurfaceHolder = holder;
onSurfaceRedrawNeededNative(mNativeHandle, holder.getSurface());
}
|
private native void | unloadNativeCode(long handle)
|