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 manually add the Activity lifecycle callbacks (rather than extend TuneApplication), 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.onResume(Activity activity)
    TuneActivity.onPause(Activity activity)

    in your Activity’s respective lifecycle events:

    import android.os.Build;
    import com.tune.Tune;
    import com.tune.ma.application.TuneActivity;
    
    public class MainActivity extends SomeOtherActivityNotTuneActivity {
        @Override
        protected void onResume() {
            super.onResume();
            if (Build.VERSION.SDK_INT < 14) {
            TuneActivity.onResume(this);
            }
        }
      
        @Override
        protected void onPause() {
            super.onPause();
            if (Build.VERSION.SDK_INT < 14) {
            TuneActivity.onPause(this);
            }
        }
    }
    

No Comments

Leave a reply