如何确定应用程序是作为移动应用程序还是桌面应用程序运行?
我怎样才能知道当前的应用程序类型是什么?即它是在移动设备上运行还是作为桌面 Air 应用程序运行?
我已经尝试过:
if(FlexGlobals.topLevelApplicatoin as WindowedApplication)
//desktop
但是移动版本找不到 WindowedApplication
类。
我如何区分?
How can I find out what the current application type is? i.e. whether it's running on a mobile device or as a desktop Air application?
I've tried this:
if(FlexGlobals.topLevelApplicatoin as WindowedApplication)
//desktop
However the mobile Version can't find the WindowedApplication
class.
How do I tell the difference?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
好的,这有效:
ok this works:
您可以使用 Capability.OS;但是请注意文档中的警告:
You can use Capabilities.OS; however heed this warning from the docs:
这是我用来确定它是哪个操作系统以及是否是移动操作系统的类,当然这仅涵盖 Windows、Linux Android 和 iOS:
This is the class I use for determine which os is it and if it's Mobile or not, of course this only covers Windows, Linux Android and iOS:
如果您需要知道您是在移动设备还是桌面设备上运行,您应该检查
Capability.cpuArchitecture:
If you need to know whether you are running on mobile or desktop you should check for
Capabilities.cpuArchitecture:
我不知道,
但我们无法将 FlexGlobals.topLevelApplicatinn 转换为 Mobile Application 中的 WindowedApplication。
因此,移动应用程序可以来自以下类型:
1.TabbedViewNavigatorApplication - 用于选项卡式视图导航应用程序
2.viewnavigatorapplication - 基于视图的导航应用程序
因此,作为您的应用程序类型,您应该尝试从上述两个选项进行转换......
I'm not sure,
But we can not convert FlexGlobals.topLevelApplicatinn into WindowedApplication in Mobile Application.
So, Mobile Applications can be from the following types:
1.TabbedViewNavigatorApplication - for Tabbed View Navigation Application
2.viewnavigatorapplication - view based navigation application
So as your application type you should try from above two options for conversion....
此测试将在移动应用程序中进行,无需测试特定操作系统名称(例如 Capability.os 或 Capability.version)。它的优点是在桌面上调试移动应用程序时能够始终如一地工作,而 Capability.os 可能无法为您提供所需的答案:
This test will work from a mobile app without needing to test for specific OS names (like Capabilities.os or Capabilities.version). It has the advantage of working consistently when debugging a mobile app on the desktop as well where Capabilities.os may not give you the answer you want:
C# 函数检查 IOS(iPad, iPhone)
C# Function to check IOS(iPad, iPhone)