MicroStrategy ONE

Log Out Users in Android

If you have the MicroStrategy Library app and your own management app installed on the same Android device, you can logout user sessions in Library when certain status changes occur in the management app.

The Logout API is provided in the Library Mobile SDK to logout all sessions. Here is the logout method and description in com.microstrategy.android.MstrApplication:

Modifier and Return Type

Method and Description

public static void

logout(final LogoutCallback callback)

@param callback The callback to invoke after logout

Used to logout from all servers in the server list. Closes all sessions against the Intelligence server and unregisters push notifications.

Here is the onLogoutFinish method and description in com.microstrategy.android.infrastructure.sdk.LogoutCallback:

Modifier and Return Type

Method and Description

void

onLogoutFinish(boolean success)

@param success Determines whether the logout is a success or failure.

The action to invoke after the logout is complete.

Log out the Library app from another app

In this procedure, there are two apps, the MicroStrategy Library Mobile SDK app and another app. The other app allows MicroStrategy Library Mobile SDK to log out when it is in a certain state. Once the MicroStrategy Library Mobile SDK app receives the logout broadcast, it invokes the logout from inside the app.

  1. Set up the environment to use the Library Mobile for Android project. You are using this project as the basis for your customizations.
  2. Next, let's implement the AppDelegate interface. Open the project in Android Studio.
  3. Switch your Tool window to the Project perspective.
  4. Navigate to src > main.
  5. Right-click the main folder and create a new directory named java, to hold all of your Java source files.
  6. Under the java directory, create a new package named com.example.
  7. Create a new java class named LogoutReceiver under the package that extends the BroadcastReceiver class.
  8. Override the onReceive(Context context, Intent intent) function to logout the app by calling the Logout API.

    Copy
    import com.microstrategy.android.infrastructure.sdk.LogoutCallback;
    public class LogoutReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            MstrApplication.logout(new LogoutCallback() {
                @Override
                public void onLogoutFinish(boolean success) {
                    // put post logout operation here
                }
            });
        }
    }

  9. Navigate to src > main > AndroidManifest.xml.
  10. In the manifest, declare the LogoutReceiver class you created earlier and specify the action to match the intent action for the broadcast.

    Copy
    <application...>
    ...
      <receiver android:name="com.example.LogoutReceiver" android:exported="true"> <!-- replace the receiver class name with your own --> 
          <intent-filter>
              <action android:name="ACTION_NAME"/>
          </intent-filter>
      </receiver>
    ...
    </application>

  11. Navigate to the other app. When it hits a certain state, send out a broadcast to the logout receiver to logout the Library app. You need to have an activity or application to send the broadcast.
  12. Copy
    public void sendLogoutBroadcast(Context context) {
        Intent i = new Intent();
        i.setAction(“ACTION_NAME");
        i.setClassName(“SDK_PACKAGE_NAME", "com.example.LogoutReceiver");
        context.sendBroadcast(i);
    }