开发者

HTC Sense Copy/Paste API's

开发者 https://www.devze.com 2023-01-11 05:20 出处:网络
Is there a way to access the copy/paste api/UI in an Android / HTC Sense based phone? I really like the way a long press works i开发者_如何学Pythonn a large canvas while using Sense. Is there a way t

Is there a way to access the copy/paste api/UI in an Android / HTC Sense based phone?

I really like the way a long press works i开发者_如何学Pythonn a large canvas while using Sense. Is there a way to programmatically detect code is running on a Sense-based phone and call out to those APIs?


No, very certainly not. There is only one copy/paste API in Android, though implementation details may differ between skins, if you can call it an API even because it comes for free if you choose the right UI elements.

I also do not know what you mean by "the way a long press works in a large canvas while using Sense". When I compare copying text and selecting text in stock Android and HTC Sense it mostly is the same (except for colors etc.). Could you make your question more specific?

Edit: Maybe you meant this: Add my app to HTC cut & paste sendto menu


Ok, I have to be honest here, I haven't played with android yet, although I'm planning to do that soon. However I have been working on the Microsoft Surface table.

If the standard android library does not implement functionality to detect some sort of touch and hold event I suggest the following:

I think you could easily implement such helper yourself. What you will probably want to do is add a listener to the touch event of that canvas. At the moment a finger touches the canvas, you start running a timer. When the timer ends, you fire your desired event. However, this will also need you to implement a few other things. When the finger moves outside a certain threshold, or the finger is lifted again, the timer needs to be stopped and cleaned up so it won't fire anymore.

In this scenario you have created the touch and hold scenario for yourself. All you have to pay attention to is that you break it off on added touch-manipulation.

(I really reckon the standard touch library must contain something similar to this functionality though!)


From what I was able to find with a few searches was:

@Override
public void onLongPress(MotionEvent e)
{
    //Call your own custom copy paste dialog here.
}

(Otherwise you might find something to your liking in the GestureDetector?)

The copypaste functionality uses the ClipboardManager. All you need is to create a popup menu containing copy and paste images with the associated text and a hooks to that ClipboardManager.


I'm new to Android development as well, but I think what you are looking for is the R.id class. Here's the API documentation link:

http://developer.android.com/reference/android/R.id.html

This looks like how it's used:

menu.add(0, android.R.id.copy, menuIndex++, android.R.string.copy);

menu.add(0, android.R.id.paste, menuIndex++, android.R.string.paste);

Good luck with your app!

Sam

0

精彩评论

暂无评论...
验证码 换一张
取 消