0

Apache Felix を Android アプリケーションに埋め込んでいます。バンドルの開始と停止は正常に機能します。しかし、別のバンドル ファイルを読み取ってバンドルを更新したいと考えています。これが私のコードです:

bundle1 = bundleContext1.installBundle("file:sdcard/Download/AndroidImageViewer_1.0.0.201308221559.jar");
            bundle1.start();
            bundle1.stop();
            try {
                bundle1.update(new FileInputStream(new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar")));
            } catch (FileNotFoundException e) {e.printStackTrace();}
            bundle1.start();

これが機能し、バンドルが更新されることを期待していましたが、残念ながら、次のエラーが発生しました。

    java.io.FileNotFoundException: /file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar (No such file or directory)
    at org.apache.harmony.luni.platform.OSFileSystem.open(Native Method)
    at dalvik.system.BlockGuard$WrappedFileSystem.open(BlockGuard.java:239)

この例外は次の行で発生します。

bundle1.update(new FileInputStream(new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar")));

バンドルがダウンロードディレクトリに存在することは完全に確信しており、AndroidVideoPlayer_1.0.0.201308231205.jar以前に開始しようとしましたが、正常に機能しました。私は混乱しています。何か助けはありますか?ありがとう。

4

1 に答える 1

1

ああ、あなたは URL から File オブジェクトを作成しています!

 new File("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar"))

これを試して

 File file = new File( "sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar" );
 context.update( new FileInputStream(file));

または

 context.update( new URL("file:sdcard/Download/AndroidVideoPlayer_1.0.0.201308231205.jar").openStream());
于 2013-09-02T11:20:32.960 に答える