Update SDK from 2.x to 3.x

If you are updating from an existing Social Login for Android implementation to 3.0.0, you should:

1. Update AndroidManifest.xml

The Activity definitions for the library have been updated for version 3.0. To use the new definitions remove the three existing Activity definitions from your AndroidManifest.xml file and copy in the fresh definitions from JREngage/AndroidManifest.xml.

2. Handling Android Application Restarts

Android was initially designed for systems with few computing resources, including limited available RAM. In order to avoid running out of RAM, the system can kill background applications to reclaim needed resources. Before killing background applications, the system will offer them a chance to save their instance state. The saved instance state is meant to be a small kernel of state from which the entire application can be recreated.

Use the New Library Initialization Method

Version 3.0 of the SDK now accepts an Android Context object for initialization where it used to require an Activity object. Initializing with a Context allows you to initialize the library from an Android Application object in the Application object’s onCreate method, rather than initializing in an Activity object. (Activity objects are Context subclasses, so it is still okay to initialize the library in an Activity object.) To initialize from an Application object, first define a new class as shown below, replacing MY_APP_ID and MY_TOKEN_URL with your values:

public class MyApplication extends Application implements JREngageDelegate {
   public JREngage mEngage;

   public void onCreate() {
      super.onCreate();
      mEngage = JREngage.initInstance(this, MY_APP_ID, MY_TOKEN_URL, this);
   }
...
}

Then, in your AndroidManifest.xml file, add the android:name attribute to yourelement and give it the value of the fully qualified name of your Application subclass. For example:

...
...
   <application
      ...
      android:name="com.myorganization.myapplicationpackage.MyApplication"
      ...
   />
...

Then, whenever your application starts or restarts, the library is always initialized and ready to go when you wish to use it.

Initializing with a Context has two advantages:

3. Use the New Library Launch Methods

When you invoke the library’s authentication or publishing screens, the library starts new Android activities to fulfill those requests. Android activities operate in stacks, one on top of another, so in order to launch an Android activity, you must launch it from an existing activity. The library now accepts an Activity object parameter in all of the JREngage#show...Dialog(...) methods. The new authentication or sharing activity launches on top of the activity parameter passed into the method. If you have initialized the library with a Context, then you need to use one of the new method signatures. For example:

public class MyActivity extends Activity {
   ...
   public void startJanrainAuthentication() {
      JREngage engage = ((MyApplication) getApplication()).mEngage;
      engage.showAuthenticationDialog(this);
   }
}