Embedding Knopflerfish in Android doesn't work

瘦欲@ 提交于 2019-12-01 00:26:35

At the comment // add any framework properties to fwprops, I only had to add the Framework launching property specifying the persistent storage directory used by the framework. Since it is Android, the default value for the storage directory doesn't seem to work. Instead, I should specify the directory under sdcard. Hence, I added this line:

 fwprops.put("org.osgi.framework.storage", "sdcard/fwdir");

Below is my updated code:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Map<String, String> fwprops = new Hashtable<String, String>(); //CHANGED

        // add any framework properties to fwprops
        fwprops.put("org.osgi.framework.storage", "sdcard/fwdir");

        FrameworkFactory ff = new FrameworkFactoryImpl();
        mFramework = ff.newFramework(fwprops);

        try {

            mFramework.init(); //THIS WORKS NOW :P :P

        } catch (BundleException be) {
            // framework initialization failed

            Log.d(TAG, be.getStackTrace().toString());

        }

    }  

Thanks to these two links: http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/Constants.html#FRAMEWORK_STORAGE http://www.knopflerfish.org/releases/current/docs/bundledoc/index.html?docpage=framework/index.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!