| 185 | } |
| 186 | |
| 187 | private void load() { |
| 188 | // Interestingly, NativeActivity uses a different method |
| 189 | // to find native code to execute, avoiding |
| 190 | // System.loadLibrary. The result is Java methods |
| 191 | // implemented in C with JNIEXPORT (and JNI_OnLoad) are not |
| 192 | // available unless an explicit call to System.loadLibrary |
| 193 | // is done. So we do it here, borrowing the name of the |
| 194 | // library from the same AndroidManifest.xml metadata used |
| 195 | // by NativeActivity. |
| 196 | try { |
| 197 | ActivityInfo ai = getPackageManager().getActivityInfo( |
| 198 | getIntent().getComponent(), PackageManager.GET_META_DATA); |
| 199 | if (ai.metaData == null) { |
| 200 | Log.e("Go", "loadLibrary: no manifest metadata found"); |
| 201 | return; |
| 202 | } |
| 203 | String libName = ai.metaData.getString("android.app.lib_name"); |
| 204 | System.loadLibrary(libName); |
| 205 | } catch (Exception e) { |
| 206 | Log.e("Go", "loadLibrary failed", e); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | @Override |
| 211 | public void onCreate(Bundle savedInstanceState) { |