0
この場合は、受信時に.txt
というファイルにwhats'appで問題があります。
私は私の活動に意図を取得:
共有ファイルを受信しました
if (Intent.ACTION_SEND.equals(action) && Objects.equals (type, "text/plain")) {
Log.d ("Intent", "have shared");
Bundle bundle = intent.getExtras();
Uri uri = (Uri) bundle.get(Intent.EXTRA_STREAM);
Log.d ("uri ",
uri.getAuthority()+" "+
uri.getPath()+" "+
uri.getFragment()+" "+
uri.getUserInfo());
File file = new File (uri.getPath());
Log.d("file" , file.toString()+" "+file.getPath()+" "+file.getName()+" "+ file.exists()+" "+ file.isFile()+" "+file.isDirectory()+" "+file.isAbsolute()+" "+file.isHidden());
try {
StringBuilder text = new StringBuilder();
BufferedReader br = new BufferedReader(new FileReader(file));
String line;
//read line by line
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
Log.d ("String", text.toString());
} catch (java.io.IOException e) {
e.printStackTrace();
}
:それは、
Bundle
を通じて
extra
を抽出し、新しい
File
を作成し、
String
にそれを変換しようと、
ACTION_SEND
ある場合
//check intent
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
制御
デバッグログの結果は次のとおりです。
D/uri: com.whatsapp.provider.media /item/95 null null
D/file: /item/95 /item/95 95 false false false true false
私はBufferedReader
に、このエラーを取得する:
W/System.err: java.io.FileNotFoundException: /item/95: open failed: ENOENT (No such file or directory)
そして私はなぜ理解していません。
誰かが私を助けることができますか?