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

查看:161
本文介绍了三星手指悬停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推荐的链接中描述的方法. 唯一要做的就是在清单中为您的Activity添加一个新的Intent过滤器,而无需覆盖"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>

之后,您必须向视图添加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天全站免登陆