MicroStrategy ONE

Customize Startup Activity in Android

You can customize startup activity for Android to add specific operations before the app launches.

  1. Create an activity class and define your operations within this class.
  2. Create an intent from MstrStartupActivity and launch the app by starting the activity. For example, if you want to display an alert dialog before the app launches, you can show this alert in the onCreate(Bundle savedInstanceState) method of the activity. The app launches after the user taps the Continue button to dismiss the alert.

    Copy
    package com.microstrategy.android;

    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.Context;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;

    import com.microstrategy.android.ui.activity.MstrStartupActivity;

    public class CustomizedStartupActivity extends Activity implements DialogInterface.OnDismissListener {
        AlertDialog alertDialog = null;

        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            //Define your operations, for example shown an alert dialog
            showAlertDialog("Welcome", "Welcome to MicroStrategy Mobile.");
        }

        private void startStartupActivity() {
            //This method can launch the mstr app after all your operations are done
            Intent intent = new Intent(this, MstrStartupActivity.class);
            Uri uriData = getIntent().getData();
            if(uriData != null) {
                //If application launched with URL, you can pass the URL to MstrStartupActivity
                intent.setData(uriData);
                intent.setAction(android.content.Intent.ACTION_VIEW);
            }
            startActivity(intent);
        }

        private void showAlertDialog(final String title, final String message){
            final Context context = this;
            AlertDialog.Builder builder = new AlertDialog.Builder(context);
            builder.setMessage(message).setTitle(title);
            alertDialog = builder.create();
            alertDialog.setOnDismissListener(this);
            alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Continue", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
            this.runOnUiThread(new Runnable() {
                public void run() {
                    alertDialog.show();
                }
            });
        }

        public void onDismiss(DialogInterface var1) {
            startStartupActivity();
        }
    }
  3. Open app/src/main/AndroidManifest.xml.
  4. Replace the line that sets up MstrStartupActivity to your activity class and set up MstrStartupActivity without intent-filter.

    Copy
        <application android:allowBackup="false" android:hardwareAccelerated="true" android:icon="@drawable/mstr_icon" android:label="@string/app_name" android:largeHeap="true" android:logo="@drawable/mstr_logo" android:name="com.microstrategy.android.MstrApplication" android:resizeableActivity="false" android:theme="@style/MSTRNativeTheme" tools:replace="android:allowBackup, android:theme">

    ...
                        
            <activity android:label="@string/app_name" android:name="com.microstrategy.android.CustomizedStartupActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>

                    <category android:name="android.intent.category.LAUNCHER"/>
                    <category android:name="android.intent.category.MULTIWINDOW_LAUNCHER"/>
                </intent-filter>
                <intent-filter>
                    <action android:name="android.intent.action.VIEW"/>

                    <category android:name="android.intent.category.DEFAULT"/>
                    <category android:name="android.intent.category.BROWSABLE"/>

                    <data android:scheme="@string/external_url_scheme"/>
                </intent-filter>
                <intent-filter>
                    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>

                    <category android:name="android.intent.category.DEFAULT"/>

                    <data android:scheme="@string/external_url_scheme"/>
                </intent-filter>
                <intent-filter>
                    <action android:name="android.nfc.action.TAG_DISCOVERED"/>
                </intent-filter>
            </activity>

            <activity android:configChanges="orientation|screenSize" android:launchMode="singleTop" android:name="com.microstrategy.android.ui.activity.MstrStartupActivity" android:theme="@style/MstrStartupActivityStyle" android:windowSoftInputMode="stateHidden">
            </activity>
    ...

        </application>

  5. Clear and rebuild the project.