Ivelius
Ivelius

Reputation: 5013

Determine if Adobe AIR preinstalled on Android device

I am developing a game using adobe AIR. I do not want to bundle the whole AIR run-time into my APK because it gets bigger in size. Instead I want to hookup with the startup of an application and check if adobe AIR is installed on the device. If it is not installed, I will send a user to Google play to download Adobe AIR.

My though was to make a native Android extension and code the process in Java just before the application starts. Until now I couldn't really find that place where I can do the check. Because as soon as the application starts and it doesn't find an AIR app installed , it crashes with exception : java.lang.UnsatisfiedLinkError: Native method not found: com.adobe.air.AIRWindowSurfaceView.nativeSurfaceCreated:()

Any ideas ?

Upvotes: 1

Views: 312

Answers (1)

Ed_Fernando
Ed_Fernando

Reputation: 378

You can use getPackageInfo (String packageName, int flags) provided you know the name of the package, hence the app, you're looking for.

Here is a code snippet that I've tested and it works fine.

try {
        this.getPackageManager().getPackageInfo("com.adobe.air", 0);

        //continue if Adobe AIR is installed
        Toast.makeText(this,"ADOBE AIR FOUND",Toast.LENGTH_LONG).show();

    } catch (PackageManager.NameNotFoundException nameNotFound) {

        //measures to be taken if Adobe AIR is not installed
        Toast.makeText(this,"ADOBE AIR ABSENT",Toast.LENGTH_LONG).show();

        //launches the Play Store listing for Adobe AIR for installation
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse("market://details?id=com.adobe.air"));
        startActivity(intent);
    }

Remember this works only as long as you know the app's package name and as long as it remains unchanged.

EDIT :

I have no experience in Adobe AIR, so I wouldn't be of much use. Googling leads me to understand that there is no Adobe sanctioned method to do so. Nevertheless there is a link I found that seems to be able to do so, albeit a lot hacky. I leave it to your judgement.

Extending AIR for Android

Upvotes: 1

Related Questions