如何判断Android设备是否有触摸屏?

发布于 2024-09-13 09:49:34 字数 97 浏览 15 评论 0原文

我花了相当多的时间让我的 UI 仅支持键盘输入。但最终我不确定我是否可以相信 Android 设备都有触摸屏的假设。

有没有办法判断Android设备是否有触摸屏?

I'm spending considerable time in making my UI to work with keyboard input only. But in the end I'm not sure whether I can rely on the assumption that Android devices all have touch screens.

Is there a way to determine if an Android device has a touch screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

只是我以为 2024-09-20 09:49:34

您应该研究现有设备并阅读 Android 兼容性定义文档 (CDD) 并决定为了你自己。

我花了相当多的时间试图自己解决这个问题。上面的海报是正确的,Android 已经为一些非触摸设备提供支持,并且将在不久的将来为 Google TV 提供支持,但就目前情况而言,CDD 特别要求所有 Android 设备必须配备触摸屏

基本上,Android 兼容性计划的创建是为了对冲某种 您现在担心的碎片问题。它列出了一系列要求,如果设备不满足这些要求,则无法访问 Android Market。这些要求包括触摸屏、无线通信、蓝牙、摄像头等等。

如果您研究这些平板电脑和上网本,您会发现没有一台带有 Android Market。 Augen 最近试图用他们的新 GENTOUCH 78 平板电脑来快速实现这一目标,但不得不 撤销他们声称该平板电脑在被 Android 兼容性团队击落后将搭载 Android Market 的声明。

因此,如果您仅通过 Android Market 分发应用程序,那么在 Google 更改 CDD 之前您无需担心。但是,如果您想在其他应用程序商店上提供您的应用程序或直接下载,那么您将不得不担心按键模式导航问题。

如果有什么安慰的话,我发现很多很多应用程序都存在完全相同的问题;如果没有触摸屏,它们就无法使用。他们中的许多人还存在焦点和软键盘的严重问题。有时,本应隐藏的键盘却处于打开状态。有时,无论您单击 EditText 多少次,都无法弹出键盘。在我看来,Android 框架并不能很好地处理这些事情。

考虑到这一切,看看谷歌电视如何适应这一切肯定会很有趣。他们会更新 CDD 以与他们的机顶盒兼容吗?他们会使用不同的 SDK 和 CDD 来实现 Google TV 吗?当涉及到 Google TV 时,他们会完全忽略兼容性计划吗?你的猜测和我的一样好。

更新:
看来 Google 终于有人站出来承认 Android 还没有准备好在平板电脑上运行:
http://phandroid.com/2010/09/10/shocker-google-says-android-not-meant-for-tablets-in-its-current-state/

对我来说,这表明 Google没有为 Android 操作系统的加速采用做好准备,也没有充分规划该平台的未来。支持大于 480x800 的屏幕几乎是不可能的,三星只能通过在 Galaxy Tab 上与谷歌密切合作才能做到这一点。所以我不太确定我们在不久的将来是否需要担心非触摸屏设备。我确信他们最终会来到这里,但当他们真正到达时,我们可能会看到一个专门针对这些人的单独的应用程序市场,或者现有市场上的一些改变的过滤方案,一个新的 CDD,谁知道呢。

对我来说,这表明谷歌仍在见机行事,我们也必须这样做。

You should research the existing devices and read the Android Compatibility Definition Document (CDD) and decide for yourself.

I have spent some considerable time trying to figure out this problem for myself. The posters above are correct that Android already powers some non-touch devices and will power Google TV in the near future, but as it currently stands, the CDD specifically requires that ALL Android devices MUST have a touchscreen.

Basically, the Android Compatibility program was created to hedge against the sort of fragmentation issues you're worrying about now. It lists a bunch of requirements, and if a device does not meet those requirements, it does not get access to Android Market. These requirements include a touchscreen, wireless communication, bluetooth, a camera, and much more.

If you research those tablets and netbooks, you will find that not a single one carries the Android Market. Augen recently tried to pull a fast one with their new GENTOUCH 78 tablet, but had to rescind their claims that the tablet would carry Android Market after being shot down by the Android Compatibility Team.

So, if you are only distributing your app through Android Market, you have nothing to worry about until Google changes the CDD. But if you'd like to offer your app on other app stores or as a direct download, then you'll have to worry about your key mode navigation issues.

If it's any consolation, I have found that many, many apps have the exact same problem; they are impossible to use without a touchscreen. Many of them also have serious issues with focus and the soft keyboard. Sometimes the keyboard stays up when it should be hidden. Sometimes you can't get the keyboard to pop up no matter how many times you click on an EditText. IMO, the Android framework does not handle these things all that well.

Given all that, it will certainly be interesting to see how Google TV fits into all this. Will they update the CDD to be compatible with their set-top boxes? Will they use a different SDK and CDD for Google TV implementations? Will they ignore the Compatibility Program altogether when it comes to Google TV? Your guess is as good as mine.

Update:
It seems that someone at Google has finally come forward and admitted that Android is not ready to run on a tablet:
http://phandroid.com/2010/09/10/shocker-google-says-android-not-meant-for-tablets-in-its-current-state/

To me, this says that Google was not prepared for the accelerated adoption of the Android OS and has not adequately roadmapped the future of the platform. Supporting screens larger than 480x800 is barely possible, and Samsung was only able to do it by working closely with Google on the Galaxy Tab. So I'm not so sure we need to worry about non-touchscreen devices in the near future. They'll be here eventually, I'm sure, but when they do arrive we may see a separate app market just for those, or some altered filtering scheme on the existing market, a new CDD, who knows.

To me, this says that Google is still playing it by ear, and we'll just have to do the same.

沉默的熊 2024-09-20 09:49:34

到目前为止,所有手机都配备了触摸屏,但没有人承诺它们必须配备。

然而,许多上网本、笔记本电脑以及即将推出的电视都没有触摸屏。
然而这些设备有鼠标。据我所见,鼠标输入通过触摸系统传递,因此 MouseDown 是 ACTION_DOWN 等...(但不知道右键单击)

All the phones so far have touch screens, but there is no promise that they must.

However there are lots of netbooks, notebooks, and soon to be TVs that have no touch screen.
However these devices have mice. From what I've seen, the mouse input gets pumped through the touch system so MouseDown is ACTION_DOWN, etc... (Don't know about right click though)

十年不长 2024-09-20 09:49:34

您的目标只是手机吗? Android 出现在许多设备上 包括电视我不知道是否会发布新的库来将设备的各个部分相互隔离,但如果您想要更广泛的受众,我建议您保留键盘输入可用

Are you targetting just the phones? Android is appearing on many devices including TV's I've no idea if new libs will be released to isolate parts of the devices from each other, but if you want a broader audience I'd suggest keeping the keyboard input available if you are

贱人配狗天长地久 2024-09-20 09:49:34

Google TV (GTV) 是最流行的 Android notouch 设备(截至撰写本答案时)。但是,如果您有“notouch”资源(例如像 res/layout-notouch/ 这样的目录),有几种设备将调用 notouch 渲染。

为了适应 notouch 设备,请确保焦点将导致视觉选择指示器,并且(对于GTV)表明击键侦听器位于方向键中心按钮的位置。使用默认的小部件和主题通常可以自动完成大部分工作。如果您制作自己的按钮,则需要用于聚焦和聚焦+按下的背景 9 块。

在 GTV 上运行是一个很好的测试环境,可以确保 notouch 正常工作,并且 GTV 有一个现在模拟器,尽管它仅在 Linux/x86 上运行。

Google TV (GTV) is the most popular Android notouch device (as of the time this answer is composed). However, there are several devices that will call for notouch renderings if you have "notouch" resources (e.g. a directory like res/layout-notouch/ )

To accommodate notouch devices, made sure that focus will cause a visual selection indicator, and (for GTV) that keystroke listeners are in place for the directional-pad center button. Using default widgets and themes will often accomplish much of this automatically. If you make your own buttons, you need background 9-patches for focused and focused+pressed.

Running on a GTV is a good test environment to make sure that notouch works well, and GTV has an emulator now, though it runs only on Linux/x86.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文