Jos*_*ude 9 android action android-intent
我的应用程序应该处理共享文本.例如亚马逊应用程序的URL.所以我在主要活动中添加了以下intent-filter:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)
在我的活动的onCreate函数中,我正在处理这样的意图:
intent = getIntent();
if(intent.getAction() != null) {
if (intent.getAction().equals(Intent.ACTION_SEND)) {
if (intent.getType().equals("text/plain")) {
onNavigationDrawerItemSelected(1);
}
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,有时在共享操作之后不会调用onCreate函数.我检查了onResume方法,实际上这就是所谓的.问题是intents操作不是"ACTION_SEND",而是packagename.handled并且不包含所需的信息.
这是为什么?
如果您的活动已存在,则根据Intent
标志和<activity>
属性,可以重用现有活动实例.重写onNewIntent()
以将Intent
正在传递到现有活动实例,从而使其返回到前台.在那里寻找你的ACTION_SEND
价值观.
归档时间: |
|
查看次数: |
360 次 |
最近记录: |