三星用手指悬停 API [英] Samsung hovering API with finger

查看:35
本文介绍了三星用手指悬停 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

三星在悬停 API 方面做得很好,我很想将它包含在我的应用中.问题在于 SPen SDK 中包含的悬停 API 仅适用于 SPen 和不像三星 Galaxy S4 上的最新应用那样使用手指检测.

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.

谁能给我一个正确的 SDK 的链接,甚至是一个示例项目?

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

Nifhel 评论,请访问此链接:Galaxy S4 上的浮动触摸(需要 API 12 并创建一个从 TextView 继承的新类,例如)

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)

接受的答案是一个更好的解决方案,并且运行良好(需要 API 14,但更易于使用).

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

推荐答案

我已经尝试了 Nifhel 推荐的链接中描述的方法.您唯一需要做的就是在清单中为您的活动添加一个新的意图过滤器,无需覆盖dispatchGenericMotionEvent":

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>

之后,您必须向您的 View 添加一个 onHoverListener ,它会正常工作.例如在我的 ListAdapter 中:

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;
    }
});

这篇关于三星用手指悬停 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆