android - 如何在 Android AIR 应用程序的 native 扩展中使用 GooglePlayServices 库?

标签 android flash air air-native-extension

我正在尝试使用 Google Play 服务库的某些功能,但我无法使其工作。我已将对 google play 服务库的引用添加到 list 文件(来自 Flash Builder)

<application android:enabled="true">
<meta-data  android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
<activity android:excludeFromRecents="false">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
</activity>
</application>

在我的 ANE 中,我添加了对 google-play-services_lib 源的引用,但是当我尝试调用 FREFunction 来检查 Google Play 服务的可用性时

@Override
public FREObject call(FREContext context, FREObject[] args){
     boolean result = false;
     try{
      Activity activitiy = context.getActivity();
      activityContext = activitiy.getBaseContext();
          result = isGooglePlayServiceExists();

     }catch(IllegalStateException e){
      Log.e(AneUtils.TAG, "Failed to get AIR current activity", e);
 }

     FREObject obj = null;
    try{
        obj = FREObject.newObject(result);
    }catch(FREWrongThreadException e){
        Log.e(AneUtils.TAG, "Failed to create FREObject from [" + result + "]");
    }


    return obj;
}

private boolean isGooglePlayServiceExists(Context activityContext){
    int googlePlayServicesCheck = -1;
    try{
        googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activityContext);
    }catch(Exception e){
        Log.e(AneUtils.TAG, "Error getting googlePlayService state",e);
    }

    if(googlePlayServicesCheck == ConnectionResult.SUCCESS){
         return true;
    }
    return false;
}

ANE 在 GooglePlayServicesUtil.isGooglePlayServicesAvailable(activityContext) 行崩溃,所以我真的怀疑没有添加 Google Play 服务库。

有人成功将 Google Play 服务库导入 Adob​​e AIR Android 应用程序吗?

任何建议或帮助将不胜感激。谢谢。

最佳答案

对于寻找答案的任何人,希望这对您有所帮助: 为了让我们在我们的 ANE 中使用任何 Google Android 库(或第 3 方 Android 库),您必须找出您的 Android 库的真实版本号,然后将该编号插入您的 list 文件。 例如,代替

<meta-data  android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />    

我们必须找出真正的版本号,您的 list 数据应该是:

<meta-data  android:name="com.google.android.gms.version"
            android:value="4432145" />

在本例中,数字 4432145 是我们要使用的 GooglePlayService 库的版本号。您可以在 Android 库项目的资源中找到此编号。 将来如果你想升级到使用最新版本的 GooglePlayService 库,你必须重建你的 ANE 文件并将版本号更正为 list 文件中库的新版本号。

关于android - 如何在 Android AIR 应用程序的 native 扩展中使用 GooglePlayServices 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22851800/

相关文章:

c++ - flash.net.Socket 和 C++ winsock WSAECONNRESET

ios - 使用 Dropbox 在空中分发应用程序时出错

android - 使用 map 、播放服务、分析等的 Android 应用程序中的 SSL 证书固定

actionscript-3 - Adobe Flash中的背景音乐不断重复吗?

Android 5.1.1 开发者选项 - USB 调试不显示

actionscript-3 - 闪存引用错误: "Cannot create property __id0_ on MyMovieClip"

ios - 如何减小 AIR 应用程序文件大小?

ios - CodeSign 验证失败 - Adob​​e Flash AIR iOS

java - 如何获取此 ListActivity 来更新信息?

php - php 中的 $_POST 未使用 Volley 库 JsonObjectRequest(方法 POST)填充