首页 \ 问答 \ 在Android中创建自定义硬件传感器(Creating custom hardware Sensors in Android)

在Android中创建自定义硬件传感器(Creating custom hardware Sensors in Android)

我正在研究在Android中创建自定义传感器,并且想知道是否有人尝试过此操作。 我希望除了使用Android Open Accessory Development Kit之外,还有一种创建自定义传感器的方法。

例如,我制造了一个定制的硬件,内置了两个水位读取器。有没有办法通过SensorManager将这些硬件暴露给Android操作系统? 以前有人试过吗? 基本上有一种方法可以将自定义传感器项添加到SensorManager。

非常感谢


I'm looking into creating custom sensors in Android and was wondering if anybody has attempted this. I was hoping there might be a way of creating custom sensors other than by using Android Open Accessory Development Kit.

For example, I manufacture a bespoke piece of hardware which has two water level readers built in. Is there any way of of exposing these to the Android OS via the SensorManager? Has anyone attempted this before? Essentially is there a way of adding custom Sensor items to the SensorManager.

Thanks a lot


原文:https://stackoverflow.com/questions/8429039
更新时间:2023-07-24 09:07

最满意答案

这是干净的代码

<html>
<head>
    <style>
        #slideshowController1
        {
            position: absolute;
            left: 50%;
            top: 0;
            width: 50%;
            height: 100%;
            z-index: 98;
            border: 1px solid blue;
        }

        #slideshowController2
        {
            position: absolute;
            left: 0;
            top: 0;
            width: 50%;
            height: 100%;
            z-index: 98;
            border: 1px solid green;
        }

        #pic1
        {
            height: 400px;
            width: 400px;
            border: 1px solid red;
        }

        #delete1
        {
            float: right;
            width: 24px;
            height: 24px;
            margin-top: 0px;
            background-color: black;
        }

        .swipe
        {
            overflow: hidden;
            visibility: hidden;
            position: relative;
            width: 100%;
            max-width: 500px;
            margin: 0 auto;
            text-align: center;
        }

        .swipe-wrap
        {
            overflow: hidden;
            position: relative;
        }

        #slideShow
        {
            position: relative;
            overflow: hidden;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div id="slideShow">

        <div id="slideshowController1" class="slideshowController" onclick="alert('right');">
        </div>
        <div id="slideshowController2" class="slideshowController" onclick="alert('left');">
        </div>
        <div id="mySwipe" class="swipe" style="visibility: visible;">
            <div class="swipe-wrap" id="swipe-gallery" style="width: 2500px;">
                <div id="pic1">
                    <div id="delete1" class="thumbDelete" style="z-index: 100;" onclick="alert('delete');">
                        <img src="../../img/delete.png" width="100%">
                    </div>
                </div>
            </div>
        </div>

    </div>

    </div>
</body>
</html>

如果我把z-index:100放在mySwipe上,它的工作只是在图片的一侧......它是一个部分解决方案!

但这不是理想的操作,只有图标必须结束......

有任何想法吗 ?


Here is the clean code

<html>
<head>
    <style>
        #slideshowController1
        {
            position: absolute;
            left: 50%;
            top: 0;
            width: 50%;
            height: 100%;
            z-index: 98;
            border: 1px solid blue;
        }

        #slideshowController2
        {
            position: absolute;
            left: 0;
            top: 0;
            width: 50%;
            height: 100%;
            z-index: 98;
            border: 1px solid green;
        }

        #pic1
        {
            height: 400px;
            width: 400px;
            border: 1px solid red;
        }

        #delete1
        {
            float: right;
            width: 24px;
            height: 24px;
            margin-top: 0px;
            background-color: black;
        }

        .swipe
        {
            overflow: hidden;
            visibility: hidden;
            position: relative;
            width: 100%;
            max-width: 500px;
            margin: 0 auto;
            text-align: center;
        }

        .swipe-wrap
        {
            overflow: hidden;
            position: relative;
        }

        #slideShow
        {
            position: relative;
            overflow: hidden;
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <div id="slideShow">

        <div id="slideshowController1" class="slideshowController" onclick="alert('right');">
        </div>
        <div id="slideshowController2" class="slideshowController" onclick="alert('left');">
        </div>
        <div id="mySwipe" class="swipe" style="visibility: visible;">
            <div class="swipe-wrap" id="swipe-gallery" style="width: 2500px;">
                <div id="pic1">
                    <div id="delete1" class="thumbDelete" style="z-index: 100;" onclick="alert('delete');">
                        <img src="../../img/delete.png" width="100%">
                    </div>
                </div>
            </div>
        </div>

    </div>

    </div>
</body>
</html>

if I put z-index:100 on mySwipe, it's work but only out side of the picture... its a partial solution !

But this is not the desired operation, only the icon must be over...

Any ideas ?

相关问答

更多
  • #footer a { pointer-events: auto; } #footer a { pointer-events: auto; }
  • 将中心区域的z-index设置为小于菜单的值。 在你的小提琴示例中,这与零值一起工作。 // JavaScript { xtype: 'panel', region: 'center', cls: 'panel-center' } // CSS .panel-center { z-index: 0; } Set the z-index of the center region to a value less than the menu's. In your fiddle ...
  • 似乎我只是误解了一些方法的目的。 将revertSelectedItem()更改为如下所示: public void revertSelectedItem() { list.setItemChecked( selected_item, true ); } 表现完全像我想要的。 看起来ListView使用项目的“已检查”状态而不是选择来决定标记哪些项目。 当在choiceMode="singleChoice" ,调用setItemChecked()也会自动取消setItemChecked()所有其他 ...
  • 这是干净的代码