0

I am embedding Apache Felix into an android app. Right now, i use the following code to install a bundle:

imageBundle = bundleContext1.installBundle("file:sdcard/Download/AndroidImageViewer_1.0.0.201308221559.jar");

This works OK, but it requires the bundle to be stored in the sdcard of the android device. However, I don't like that. I want the bundle to be stored in a directory inside the android project. For example, inside the assests folder. Is there a way to achieve this?

I tried this:

imageBundle = bundleContext1.installBundle("file:assets/bundles/AndroidImageViewer_1.0.0.201308221559.jar");

and as expected, it didn't work.

Traveling Salesman
  • 2,209
  • 11
  • 46
  • 83

1 Answers1

0

The url is wrong. The correct URL would be something like

file:///android_asset/AndroidImageViewer_1.0.0.201308221559.jar

as pointed out here.

Community
  • 1
  • 1
Audrius Meškauskas
  • 20,936
  • 12
  • 75
  • 93
  • I did what you say but It didn't work. I got this: 08-23 19:14:02.159: W/System.err(6963): Caused by: java.io.FileNotFoundException: /android_asset/bundles/AndroidVideoPlayer_1.0.0.201308231205.jar (No such file or directory) – Traveling Salesman Aug 23 '13 at 15:14
  • You file is in the asset subfolder *bundles*. The correct path in this case is file:///android_asset/bundles/AndroidVideoPlayer_1.0.0.201308231205.jar – Audrius Meškauskas Aug 23 '13 at 15:17
  • I think this doesn't work all the time. In the link you are providing, one answer was: "Works for WebView but seems to fail on URL.openStream(). So you need to distinguish file:// protocols and handle them via AssetManager as suggested." – Traveling Salesman Aug 23 '13 at 15:23
  • Best I can propose, then, is maybe to tweak Felix source code in Android specific way. It is open source. – Audrius Meškauskas Aug 23 '13 at 15:43