私は2つのアプリケーションを送信イメージ用に、もう1つを受信用に開発しています。イメージファイルまたはビットマップを送信するのと同じ問題があります。 私はすでに多くのQ & Aを読んでいますが、助けてくれません。イメージ送信(ビットマップ/ファイル)インテントAndroid
第一のAppマニフェスト
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application ...>
<activity ...>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
(ビットマップを使用して)第一のAppクラス
try {
//Write file
String filename = "bitmap.png";
FileOutputStream stream = this.openFileOutput(filename, Context.MODE_PRIVATE);
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
//Cleanup
stream.close();
bitmap.recycle();
//Pop intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra("image", filename);
startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
第二のAppマニフェスト
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application ...>
<activity ...>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
</activity>
</application>
第二のAppクラス
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
imageView = (ImageView) findViewById(R.id.imageView);
if (Intent.ACTION_SEND.equals(action) && type != null) {
if (type.startsWith("image/")) {
Bitmap bmp = null;
String filename = intent.getStringExtra("image");
try {
FileInputStream is = this.openFileInput(filename);
bmp = BitmapFactory.decodeStream(is);
is.close();
imageView.setImageBitmap(bmp);
} catch (Exception e) {
e.printStackTrace();
}
}
}
エラーは、私はファイルから私は同じエラーを取るuriを送信しようとすると、常に持っている。 (私は2番目のアプリケーションで開いたファイルことはできませんが、私は私がそう多くの場所が、何の助けに保存して開こうとした方法を開いて、知らないからだと思います)
03-22 14:52:05.412 1286-1818/? I/ActivityManager: START u0 {act=android.intent.action.SEND typ=image/* cmp=com.example.k.handleintents/.MainActivity (has extras)} from uid 10064 on display 0
03-22 14:52:05.467 3069-3069/? W/System.err: java.io.FileNotFoundException: /data/user/0/com.example.k.handleintents/files/bitmap.png: open failed: ENOENT (No such file or directory)
03-22 14:52:05.467 3069-3069/? W/System.err: at libcore.io.IoBridge.open(IoBridge.java:452)
03-22 14:52:05.467 3069-3069/? W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76)
03-22 14:52:05.467 3069-3069/? W/System.err: at android.app.ContextImpl.openFileInput(ContextImpl.java:384)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.content.ContextWrapper.openFileInput(ContextWrapper.java:177)
03-22 14:52:05.468 3069-3069/? W/System.err: at com.example.jorgealberto.handleintents.MainActivity.handleSendImage(MainActivity.java:85)
03-22 14:52:05.468 3069-3069/? W/System.err: at com.example.jorgealberto.handleintents.MainActivity.onCreate(MainActivity.java:46)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.Activity.performCreate(Activity.java:6237)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.ActivityThread.-wrap11(ActivityThread.java)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.os.Handler.dispatchMessage(Handler.java:102)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.os.Looper.loop(Looper.java:148)
03-22 14:52:05.468 3069-3069/? W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
03-22 14:52:05.469 3069-3069/? W/System.err: at java.lang.reflect.Method.invoke(Native Method)
03-22 14:52:05.469 3069-3069/? W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-22 14:52:05.469 3069-3069/? W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-22 14:52:05.469 3069-3069/? W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
03-22 14:52:05.469 3069-3069/? W/System.err: at libcore.io.Posix.open(Native Method)
03-22 14:52:05.469 3069-3069/? W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
03-22 14:52:05.469 3069-3069/? W/System.err: at libcore.io.IoBridge.open(IoBridge.java:438)
03-22 14:52:05.469 3069-3069/? W/System.err: ... 17 more
03-22 14:52:05.584 3069-3083/? W/EGL_emulation: eglSurfaceAttrib not implemented
03-22 14:52:05.584 3069-3083/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xabe633a0, error=EGL_SUCCESS
03-22 14:52:06.188 1286-1305/? I/ActivityManager: Displayed com.example.jorgealberto.handleintents/.MainActivity: +754ms
このファイルにアクセスするために必要なアクセス許可はありますか?それが別のアプリで、そのファイルが内部のアプリ専用ストレージに保存されている場合、それはうまく動作しません。 – m02ph3u5