当选择了文本如何火象发射事件的应用程序应用程序、选择了、文本、事件

由网友(无人像你)分享简介:我在想,如果我能当像浏览器,邮件等任何应用程序中选择文本推出的活动或应用程序。当我们选择在任何一个文本,其中一个小的弹出窗口出现提的剪切,复制,粘贴选项等。我可以添加一个按钮呢?启动我的应用程序?如果我能请指导我如何能做到这一点,将数据发送到我的应用程序。感谢您!保护无效的onCreate(包savedInstance...

我在想,如果我能当像浏览器,邮件等任何应用程序中选择文本推出的活动或应用程序。

当我们选择在任何一个文本,其中一个小的弹出窗口出现提的剪切,复制,粘贴选项等。我可以添加一个按钮呢?启动我的应用程序?

如果我能请指导我如何能做到这一点,将数据发送到我的应用程序。

如何设置Word鼠标选择文本的方式像普通文本编辑器一样

感谢您!

 保护无效的onCreate(包savedInstanceState){
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    的setContentView(R.layout.main);
    。getWindow()setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title);
 

解决方案

最接近你所描述的,这将是您的应用程序注册为处理 android.intent.action.SEND 意图,如下所述:

http://developer.android.com/training/sharing/receive.html

意图过滤器的声明看起来是这样的:

 <意向滤光器>
    <作用机器人:名称=android.intent.action.SEND/>
    <类机器人:名称=android.intent.category.DEFAULT/>
    <数据机器人:MIMETYPE =text / plain的/>
&所述; /意图滤光器>
 

的用户看到什么...

当一个用户在其他一些应用程序,如果它的应用程序,他们会得到复制和支持选择文本;你已经看到粘贴选项,但他们也将获得分享选项 - 图标为三个点由两条线路连接的:

...并且当用户然后在共享图标龙头:

您的应用程序将显示在显示给用户的应用程序的列表。如果用户选择您的应用程序,您会收到一封意向与共享文本,然后可以提取,即:

字符串sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);

进一步阅读

http://android-developers.blogspot.com/ 2012/02 /股,与-intents.html

I was wondering if i can launch an activity or application when a text is selected in any application like browser, messages etc.

Like when we select a text at any where a small pop-up appears mentioning cut, copy, paste option. can i add another button there? to launch my application?

if i can please guide me how can i do that and send data to my application..

Thank you !

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title);

解决方案

The closest thing to what you're describing would be for your app to register as handling the android.intent.action.SEND intent, as described here:

http://developer.android.com/training/sharing/receive.html

The intent-filter declaration would look something like this:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" />
</intent-filter>

What the user sees...

When a user is in some other app and selects text, if it's supported by the app they'll get the copy & paste options you've already seen, but they'll also get the 'share' option - the icon is three dots connected by two lines:

...and when the user then taps on the 'Share' icon:

Your app will appear in the list of apps that are displayed to the user. If the user selects your app, you'll receive an intent with the shared text which you can then extract, ie:

String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);

Further reading

http://android-developers.blogspot.com/2012/02/share-with-intents.html

阅读全文

相关推荐

最新文章