我有Android应用程序与意图过滤器(ACTION_VIEW)打开文件并将其导入我的应用程序.我希望从gmail应用程序下载文件附件到我的应用程序.一些文件类型(即jpg,png,txt)被正确保存,但有些不是(即doc,xls,ppt).我相信我对我的活动有正确的意图过滤器,因为它适用于其他应用程序(即dropbox),但不适用于gmail应用程序.这有什么解决方案吗?
当我将启动模式设置为"singleInstance"时,我在MYApp中打开电子邮件时遇到问题.
我附加了示例Android项目,它从电子邮件附件中读取文件名并在屏幕上显示.在onCreate的情况下工作正常但在应用程序启动模式为singleInstance时在onNewIntent中抛出错误.
Launchmode.java
package your.namespace.launchmode;
public class LaunchModeActivity extends Activity {
private static final int OPEN_ACT = 2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String name = getAttachmetName(getIntent());
if(null != name)
{
TextView textv = (TextView) findViewById(R.id.attachmentnm);
textv.setText(name);
}
}
@Override
protected void onNewIntent(Intent savedInstanceState)
{
super.onNewIntent(savedInstanceState);
String name = getAttachmetName(savedInstanceState);
if(null != name)
{
TextView textv = (TextView) findViewById(R.id.attachmentnm);
textv.setText(name);
}
}
private String getAttachmetName(Intent intent) {
final …Run Code Online (Sandbox Code Playgroud) 我必须从gmail应用程序中检索内容的文件名.
我得到的内容与某些东西类似
内容://gmail-ls/messages/mymailid%40gmail.com/4/attachments/0.1/BEST/false
我看到一些应用程序从这个应用程序获取文件名
请帮忙.
提前致谢.