This can be done and in pure and simple AS3! Read Getting Device Properties like OS, Model, Brand, SDK Version and CPU on AIR for Andoid
and take a look to Android Native Device Info
Thanks to Héctor for the link!
You thought I had the solution? Sorry.
Let's say you have an AIR app and you want to find out in which device your app is running. You could take a look to Capabilities.os
but you would only get something along the lines of "Android", "Windows", etc. And you are after something like "Samsung / Galaxy TAB".
You could also think that a combination of NativeProcess and a native app might be your solution, but you would be out of luck because is not supported when your app runs with a mobileDevice profile
If you were prepared to add an external server / service as a dependency you could think that you could make a request to your server, take a look to the user agent, parse it and return something meaningful and simple? Nice try, but browsers' user agents are very unreliable
. Have a look at the user agent from the same device (Samsung Galaxy S), but from the default browser, Opera Mobile and an AIR app respectively:
* Mozilla/5.0 (Linux; U; Android 2.2; en-gb; GT-I9000 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
* Opera/9.80 (Android; Linux; Opera Mobi/ADR-1011151731; U; en) Presto/2.5.28 Version/10.1
* Mozilla/5.0 (Android; U; en-GB) AppleWebKit/531.9 (KHTML, like Gecko) AdobeAIR/2.6
Not enough information and nowhere consistent enough to parse with a certain degree of confidence.
So, what's left? C'mon! There's got to be something
! It's right there
! You only need to make it to Build.MANUFACTURER
Well, I've got two ideas, one dirty, the other one complicated.DIRTY
: Make a native app that runs on the background, as a Service
, with a socket server. Then from Flash you just connect to that socket server passing messages back and forth. It's not that complicated
. Problems are a) it would be a separate app and specially b) it would have to be manually started, you cannot start it from the client AIR app as far as I know.COMPLICATED
: Build an AIR for Android wrapper, a-la Kuneri
. You would have to build the socket server from the option above, bundle it and pack it with the SWF, everything in one single app. I'm sure is doable, at the end of the day that's what the AIR SDK is doing, right? You wouldn't even run into legal problems, since you wouldn't distribute the AIR runtime for Android (official AIR apps for Android require the AIR runtime as a separate download).
So, am I the only one thinking that we've just found a business opportunity? AIR apps on steroids for Android with custom Java classes.
I would start right now if I didn't have to go to bed.