如何让我的应用程序,计算出(在运行时),如果是在Android Wear运行?我的、是在、计算出、应用程序

由网友(爷蹲街,戏小妞)分享简介:我知道如何让我参加竞选的内部版本号:I know how to get the build version that I'm running on:if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {try {// Update the actio...

我知道如何让我参加竞选的内部版本号:

I know how to get the build version that I'm running on:

 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
      try {
        // Update the action bar title with the TypefaceSpan instance
        final ActionBar bar = getActionBar();
        ....

我也想有一个(安培;&安培;!耐磨)在if语句,因为没有对身打扮没有动作条。这将是巨大的,如果它也包含在构建类莫名其妙。

I would also like to have an (&& !wearable) in that if statement, since there is no actionBar on wearables. It would be great if it was also included in the Build class somehow.

该应用程序是没有正式耐磨呢,但这是一些共享code部分,所以请不要告诉我,从可穿戴的活动中通过。

The app isn't officially wearable yet, but this is part of some shared code, so please don't tell me to pass it in from the wearable's activity.

谢谢!

推荐答案

如果您的真正的需要确定,如果你是一块手表,我会尝试 PackageManager hasSystemFeature(),看是否该设备的有 FEATURE_WATCH 。引用文档:

If you really want to determine if you are on a watch, I'd try PackageManager and hasSystemFeature(), to see if the device has FEATURE_WATCH. Quoting the docs:

功能的getSystemAvailableFeatures()和hasSystemFeature(字符串):这是一个专门为显示在手表的UI设备。这里的一个钟表被定义为穿在身上,或许在手腕上的装置。与设备进行交互时,用户是非常接近的。

Feature for getSystemAvailableFeatures() and hasSystemFeature(String): This is a device dedicated to showing UI on a watch. A watch here is defined to be a device worn on the body, perhaps on the wrist. The user is very close when interacting with the device.

不过,由于还有其他的方案在没有操作栏(如电视应用程序),你可能会考虑调用 getActionBar()(对于本机操作栏)或 getSupportActionBar()(对 appcompat-V7 操作栏),看看它是否返回

However, as there are other scenarios where there is no action bar (e.g., TV apps), you might consider calling getActionBar() (for the native action bar) or getSupportActionBar() (for the appcompat-v7 action bar) and see if it returns null.

阅读全文

相关推荐

最新文章