(Original: http://www.libgdx.cn/topic/46/4-4-libgdx%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95%E6%9F%A5%E8%AF%A2%E8%BF%90%E8%A1%8C%E7%8E%AF%E5%A2%83%E7%9B%B8%E5%85%B3%E5%B1%9E%E6%80%A7)
The application interface provides multiple methods to query the running environment attributes.
Obtain the current application type
Sometimes you need to perform special operations based on a specific platform. Application. GetType () is used to return the currently running platform. The example is as follows:
Switch (GDX. App. GetType ()){
Case Android:
// Android specific code
Break;
Case desktop:
// Desktop specific code
Break;
Case webgl:
// HTML5 specific code
Break;
Default:
// Other platforms specific code
}
In Android, you can also query the current Android version:
Int androidversion = GDX. App. getversion ();
This will return the current SDK version. For example, 3 corresponds to android1.5.
(Www.libgdx.cn is copyrighted. If you need to reprint it, indicate the source)
4.4. Use libgdx to query running environment attributes