动作条股项生产和QUOT; Android系统"啄 [英] ActionBar share item produces "Android System" thingy
问题描述
我要在操作栏中,在pressing每股图标,选择器显示出来。我有这个最到位,但这种不受欢迎的中间人几步之遥......
菜单:
< XML版本=1.0编码=UTF-8&GT?;
<菜单的xmlns:机器人=http://schemas.android.com/apk/res/android>
<项目机器人:ID =@ + ID / menu_share
机器人:标题=@字符串/股
机器人:showAsAction =总是
机器人:actionProviderClass =com.actionbarsherlock.widget.ShareActionProvider
/>
< /菜单>
的SherlockFragment的onCreateOptionsMenu:
@覆盖
公共无效onCreateOptionsMenu(功能菜单,MenuInflater充气){
//充气菜单资源文件。
inflater.inflate(R.menu.share_menu,菜单);
//找到菜单项与ShareActionProvider
菜单项项= menu.findItem(R.id.menu_share);
//读取和存储ShareActionProvider
this.shareActionProvider =(ShareActionProvider)item.getActionProvider();
最后字符串标题= r.getString(R.string.feedback_share);
最后弦乐主题= r.getString(R.string.share_subject);
最终字符串消息= r.getString(R.string.share_message_plain);
意向意图= app.newShareIntent(标题,主题,邮件);
this.shareActionProvider.setShareIntent(意向);
}
这样做的目的工厂:
公共意向newShareIntent(标题字符串,字符串主题,字符串消息){
意向意图=新的意图(android.content.Intent.ACTION_SEND);
intent.setType(text / plain的);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_SUBJECT,学科);
intent.putExtra(Intent.EXTRA_TEXT,消息);
意向选择器= Intent.createChooser(意向,职称);
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
返回选择器;
}
不受欢迎的中间人:
当我点击这个家伙,他做的指示和presents选择器。但我真的不有志于从事他的服务。
我后,我什么:
或者,这与所有三个(或包含很多的用户设备)在下拉...或者可以设置内联的具有共享图标默认的:
不过我真的没有兴趣从事他的服务。
但是,你问他的服务,因为你是一个谁名为 createChooser()
,并决定使用它作为你的那份意图
。
摆脱那种,退回 ACTION_SEND
意图
直接,Android系统应该消失。
I want a share icon in the action bar, upon pressing, a chooser shows up. I have most of this in place, but this unwelcome middle-man steps in...
The menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_share"
android:title="@string/share"
android:showAsAction="always"
android:actionProviderClass="com.actionbarsherlock.widget.ShareActionProvider"
/>
</menu>
The SherlockFragment's onCreateOptionsMenu:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate menu resource file.
inflater.inflate(R.menu.share_menu, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_share);
// Fetch and store ShareActionProvider
this.shareActionProvider = (ShareActionProvider) item.getActionProvider();
final String title = r.getString(R.string.feedback_share);
final String subject = r.getString(R.string.share_subject);
final String message = r.getString(R.string.share_message_plain);
Intent intent = app.newShareIntent(title, subject, message);
this.shareActionProvider.setShareIntent(intent);
}
The intent factory:
public Intent newShareIntent(String title, String subject, String message) {
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
Intent chooser = Intent.createChooser(intent, title);
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return chooser;
}
The unwelcome middle-man:
And when I click on this guy, he does as directed and presents the chooser. But I'm really not interested in engaging his services.
What I'm after:
Or this with all three (or however many on users devices) in the drop down... or be able to set the default that appears inline with the share icon:
But I'm really not interested in engaging his services.
But you asked for "his services", as you're the one who called createChooser()
and decided to use that as your share Intent
.
Get rid of that, returning your ACTION_SEND
Intent
directly, and "Android System" should go away.
这篇关于动作条股项生产和QUOT; Android系统&QUOT;啄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!