【发布时间】:2016-08-11 07:24:13
【问题描述】:
我正在尝试从其他应用程序获取 MIME 类型 text/plain 的 Intent,并将该文本存储在字符串类型的变量中。 onCreate 方法可以正常工作,但是当我使用 singleTask 作为启动模式并暂停应用程序(通过按主页按钮)并尝试将其他应用程序中的文本共享到我的应用程序时, onNewIntent(Intent intent) 方法被调用,intent.getType() 返回 null,但 onCreate 方法工作正常,我不知道为什么,请帮忙。谢谢
private String sharedData="";
@Override
protected void onNewIntent(Intent intent) {
intent = getIntent();
String action = intent.getAction();
String type = intent.getType(); //this method is returning null
if(intent.ACTION_SEND.equals(action) && type!=null)
{
sharedData = FileHandler.handleSendText(intent);//FileHandler is class i created with contains method handleSendText
}
super.onNewIntent(intent);
}
【问题讨论】: