简体   繁体   English

如何确定Android设备是否有触摸屏?

[英]How to determine if an Android device has a touchscreen?

I'm spending considerable time in making my UI to work with keyboard input only. 我花了相当多的时间让我的UI只使用键盘输入。 But in the end I'm not sure whether I can rely on the assumption that Android devices all have touch screens. 但最后我不确定我是否可以依赖Android设备都有触摸屏的假设。

Is there a way to determine if an Android device has a touch screen? 有没有办法确定Android设备是否有触摸屏?

You should research the existing devices and read the Android Compatibility Definition Document (CDD) and decide for yourself. 您应该研究现有设备并阅读Android兼容性定义文档 (CDD)并自行决定。

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 . 上面的海报是正确的,Android已经为一些非触摸设备供电,并将在不久的将来谷歌电视供电,但就目前而言,CDD特别要求所有Android设备都必须配备触摸屏

Basically, the Android Compatibility program was created to hedge against the sort of fragmentation issues you're worrying about now. 基本上,Android兼容性计划的创建是为了对冲你现在担心的那种碎片问题。 It lists a bunch of requirements, and if a device does not meet those requirements, it does not get access to Android Market. 它列出了一系列要求, 如果设备不符合这些要求,则无法访问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. 如果你研究这些平板电脑和上网本,你会发现没有一个人携带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. Augen最近尝试使用他们的新款GENTOUCH 78平板电脑进行快速测试,但不得不取消他们声称这款平板电脑在被Android兼容性团队击落后会携带Android Market。

So, if you are only distributing your app through Android Market, you have nothing to worry about until Google changes the CDD. 因此,如果您只通过Android电子市场发布应用,那么在Google更改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. 有时,无论您单击EditText多少次,都无法弹出键盘。 IMO, the Android framework does not handle these things all that well. IMO,Android框架并没有很好地处理这些事情。

Given all that, it will certainly be interesting to see how Google TV fits into all this. 鉴于这一切,看看Google TV如何适应这一切肯定会很有趣。 Will they update the CDD to be compatible with their set-top boxes? 他们会更新CDD以与他们的机顶盒兼容吗? Will they use a different SDK and CDD for Google TV implementations? 他们会为Google TV实施使用不同的SDK和CDD吗? Will they ignore the Compatibility Program altogether when it comes to Google TV? 在谈到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/ 谷歌的某个人似乎终于站出来承认Android还没有准备好在平板电脑上运行: http//phandroid.com/2010/09/10/shocker-google-says-android-not-meant-for -tablets合其电流状态/

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. 对我而言,这表明谷歌并没有为加速采用Android操作系统做好准备,也没有为该平台的未来做好充分准备。 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. 支持大于480x800的屏幕几乎是不可能的,三星只能通过与Galaxy Tab上的Google密切合作来实现这一目标。 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. 他们最终会在这里,我敢肯定,但是当他们到达时,我们可能会看到一个单独的应用程序市场,或者现有市场上的一些改进的过滤方案,一个新的CDD,谁知道。

To me, this says that Google is still playing it by ear, and we'll just have to do the same. 对我而言,这表明谷歌仍然在聆听,我们只需要做同样的事情。

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) 从我所看到的,鼠标输入通过触摸系统被泵送,因此MouseDown是ACTION_DOWN等...(不知道右键单击)

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 Android出现在包括电视在内的许多设备我不知道是否会发布新的库以将部分设备彼此隔离,但如果你想要更广泛的用户,我建议你保持键盘输入可用

Google TV (GTV) is the most popular Android notouch device (as of the time this answer is composed). 谷歌电视(GTV)是最受欢迎的Android消息设备(截至本答案撰写时)。 However, there are several devices that will call for notouch renderings if you have "notouch" resources (eg a directory like res/layout-notouch/ ) 但是,如果你有“notouch”资源(例如像res / layout-notouch /这样的目录),有几个设备会调用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. 为了适应无印刷设备,确保焦点将产生视觉选择指示器,并且(对于GTV)按键听众适用于方向键中心按钮。 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. 如果您自己创建按钮,则需要背景9补丁进行聚焦和聚焦+按下。

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. 在GTV上运行是一个很好的测试环境,以确保notouch运行良好, GTV现在有一个模拟器 ,虽然它只在Linux / x86上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM