Samsung hovering API with finger

你说的曾经没有我的故事 提交于 2019-12-03 05:36:37

问题


Samsung has done something great with the hovering API, and I'm interested in including it in my app. The problem is that the hovering API included in the SPen SDK only work with the SPen and not with the finger detection like the latest apps do on the Samsung Galaxy S4.

Can anyone provide me with a link to the right SDK or even a sample project?

EDIT: Nifhel commented, fallow this link: Floating Touch on Galaxy S4 (requires API 12 and to create a new class that inherit from TextView for instance)

EDIT: The accepted answer is a better solution and works perfectly well (requires API 14 but easier to use).


回答1:


I've tried out the method described on the link recommended by Nifhel. The only thing you have to do is adding a new intent filter for your Activity in the manifest, no need to override "dispatchGenericMotionEvent":

<intent-filter>
    <action android:name="com.sec.android.airview.HOVER" />
</intent-filter>

After that you have to add an onHoverListener to you View and it will work fine. For example in my ListAdapter:

convertView.setOnHoverListener(new OnHoverListener() {
    @Override
    public boolean onHover(View v, MotionEvent event) {
        Log.d("ListAdapter", "Hover: " + item);
        return false;
    }
});



回答2:


Based on what I could find, Samsung is yet to release an API that supports finger hovering (AirView).




回答3:


Try ApiDemos in latest version of sdk android-17 (4.2.2) -> Views -> Hover.class. It can give you a heads up on Hover event.



来源:https://stackoverflow.com/questions/16308986/samsung-hovering-api-with-finger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!