Android 电子邮件中的open.shtml附件的意图筛选器。。。
我在场景中面临的问题如下: 我有一个活动收到了一封电子邮件,随附的shtml文件。 如何打开附件 或者我该怎么处理Android 电子邮件中的open.shtml附件的意图筛选器。。。,android,android-intent,Android,Android Intent,我在场景中面临的问题如下: 我有一个活动收到了一封电子邮件,随附的shtml文件。 如何打开附件 或者我该怎么处理 请帮助您可以尝试将类似的内容附加到要处理意图的活动中。好吧,处理特定文件扩展名的唯一方法是使用pathPattern,因为我不相信您可以保证邮件应用程序将如何设置他们无法识别的文件的MIME类型 <intent-filter> <action android:name="android.intent.action.VIEW" /> <c
请帮助您可以尝试将类似的内容附加到要处理
意图的活动中。好吧,处理特定文件扩展名的唯一方法是使用pathPattern
,因为我不相信您可以保证邮件应用程序将如何设置他们无法识别的文件的MIME类型
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:pathPattern=".*\\.shtml" />
</intent-filter>
如果邮件应用程序使用不同的格式(如content://),则这两种情况下的scheme属性可能都是不必要的或有阻碍的,因此如果它不起作用,请尝试忽略该部分
HTH这是我最近一次从电子邮件中获取附件的尝试。如果你使用它,如果你把我的名字和你的来源保持在一起,那就太酷了
if (intentaction != null) {
if (intentaction.equals("android.intent.action.VIEW")) {
Uri data = intent.getData();
Uri u;
if (data != null) {
try {
pathname = data.getPath();
File f = new File(pathname);
boolean b = f.exists();
if (!b) {
pathname = null;
}
} catch (Exception e) {
pathname = null;
}
if (pathname == null) {
try {
is = new BufferedInputStream(getContentResolver()
.openInputStream(data));
_is = new BufferedInputStream(getContentResolver()
.openInputStream(data));
// _savefile = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cursor c = getContentResolver().query(data, null, null,
null, null);
if (c != null) {
c.moveToFirst();
int fileNameColumnId = c
.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
if (fileNameColumnId >= 0) {
_previewFileName = c
.getString(fileNameColumnId);
}
if (_previewFileName == null) {
fileNameColumnId = c
.getColumnIndex(MediaStore.MediaColumns.DATA);
if (fileNameColumnId >= 0) {
pathname = c.getString(fileNameColumnId);
File f = new File(pathname);
boolean b = f.exists();
if (b) {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
is = null;
try {
if (_is != null) {
_is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_is = null;
} else {
pathname = null;
}
}
}
}
}
}
}
}
// If we have an attachment
if (is != null) {
k = new KmlSummary(is);
} else if (pathname != null) {
k = new KmlSummary(pathname);
祝你好运
if (intentaction != null) {
if (intentaction.equals("android.intent.action.VIEW")) {
Uri data = intent.getData();
Uri u;
if (data != null) {
try {
pathname = data.getPath();
File f = new File(pathname);
boolean b = f.exists();
if (!b) {
pathname = null;
}
} catch (Exception e) {
pathname = null;
}
if (pathname == null) {
try {
is = new BufferedInputStream(getContentResolver()
.openInputStream(data));
_is = new BufferedInputStream(getContentResolver()
.openInputStream(data));
// _savefile = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cursor c = getContentResolver().query(data, null, null,
null, null);
if (c != null) {
c.moveToFirst();
int fileNameColumnId = c
.getColumnIndex(MediaStore.MediaColumns.DISPLAY_NAME);
if (fileNameColumnId >= 0) {
_previewFileName = c
.getString(fileNameColumnId);
}
if (_previewFileName == null) {
fileNameColumnId = c
.getColumnIndex(MediaStore.MediaColumns.DATA);
if (fileNameColumnId >= 0) {
pathname = c.getString(fileNameColumnId);
File f = new File(pathname);
boolean b = f.exists();
if (b) {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
is = null;
try {
if (_is != null) {
_is.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
_is = null;
} else {
pathname = null;
}
}
}
}
}
}
}
}
// If we have an attachment
if (is != null) {
k = new KmlSummary(is);
} else if (pathname != null) {
k = new KmlSummary(pathname);