Skip to content

Adobe AIR native extension (ANE) for Android to connect Google+

License

Notifications You must be signed in to change notification settings

manjav/air-extension-gplus

Repository files navigation

About

Adobe AIR native extension (ANE) for Android to connect to Google+ .

It uses Google Plus API (com.google.android.gms.common.api.GoogleApiClient).
Supported functionality:

  • user info (Google+ ID, name, Google+ url, email, photo url, birthdate, gender)
  • friends info (Google+ ID, name, Google+ url, photo url, gender)

Docs

Please, read docs and try ANE before asking any questions.
http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1
http://help.adobe.com/en_US/air/extensions/index.html
https://developers.google.com/identity/sign-in/android/start

Installation

Extension ID: com.gerantech.extensions.gplus
Add "gplus-extension.ane" from package folder to ane folder in your AIR project.
Add the following lines to your AIR Aplication-app.xml file inside <manifestAdditions> section:

<application android:enabled="true">
<meta-data android:name="com.google.android.gms.version" android:value="4452000" />
<activity android:name="com.gerantech.extensions.gplus.GPConnector" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
</application>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

Examples

import com.gerantech.extensions.gplus.GPlusExtension;
import com.gerantech.extensions.gplus.events.GPlusEvent;
import com.gerantech.extensions.gplus.models.Result;

...

private var extension:GPlusExtension;
...

// initialization of Google Plus API
extension = GPlusExtension.instance;
extension.addEventListener(GPlusEvent.GPLUS_RESULT , extension_eventsHandler);

...

// call this methods step by step after you dont received any error or failure message
extension.init();
...
extension.login();
...
extension.logout();
...
extension.revokeAccess();

protected function extension_eventsHandler(event:GPlusEvent):void
{
	switch(event.result.response)
	{
		case Result.CONNECTION_FAILED:
		case Result.LOGIN_CANCELED:
		case Result.LOGIN_FAILED:
		case Result.NETWORK_ERROR:
		case Result.PERSON_NULL:
		case Result.REVOKE_ACCESS:
			trace(event.result.response + "  " + event.result.success + "  " + event.result.message);
			break;
		case Result.PERSON_INFORMATION:
			trace(event.result.person.name + " " + event.result.person.email + " " + event.result.person.friends.length);
			break;
		
	}
	//trace(event.type, event.data);
}

Misc

ANE is build for AIR 18.0+, in order to rebuild for another version do the following:

  • edit "air\extension.xml" and change 18 in very first line to any X.x you need;
  • edit "package.bat" and in the very last line change path from AIR 18.0 SDK to any AIR X.x SDK you need;
  • execute "package.bat" to repack the ANE.

Thanks to

ravitamada