Getting Started Android API 14 & Below

These instructions apply for TUNE Android SDK 4.8.0 and above.

  1. For your Application class IF you do not extend TuneApplication and instead manually add the Activity lifecycle callbacks, do not try to register callbacks on devices running an Android version below API 14:
    import com.tune.ma.application.TuneActivityLifecycleCallbacks;
    
    public class MyApplication extends SomeOtherClass {
        @Override
        public void onCreate() {
            super.onCreate();
            if (Build.VERSION.SDK_INT >= 14) {
                registerActivityLifecycleCallbacks(new TuneActivityLifecycleCallbacks());
            }
        }
    }
  2. You also need to integrate all of your Activities either directly or in a shared base class to extend TuneActivity.
    import com.tune.ma.application.TuneActivity;
    
    public class MainActivity extends TuneActivity

    Note: If your Activity classes already extend another class, you may instead call:

    TuneActivity.onStart(Activity activity)
    TuneActivity.onResume(Activity activity)
    TuneActivity.onStop(Activity activity)

    in your Activity’s respective lifecycle events:

    public class MainActivity extends SomeOtherClass {
        @Override
        public void onStart() {
            super.onStart();
            if (Build.VERSION.SDK_INT < 14) {
                TuneActivity.onStart(this);
            }
        }
     
        @Override
        public void onResume() {
            super.onResume();
            if (Build.VERSION.SDK_INT < 14) {
                TuneActivity.onResume(this);
            }
        }
     
        @Override
        public void onStop() {
            if (Build.VERSION.SDK_INT < 14) {
                TuneActivity.onStop(this);
            }
            super.onStop();
        }
    }
    

No Comments

Leave a reply