Example usage for android.app Activity getApplication

List of usage examples for android.app Activity getApplication

Introduction

In this page you can find the example usage for android.app Activity getApplication.

Prototype

public final Application getApplication() 

Source Link

Document

Return the application that owns this activity.

Usage

From source file:com.uphyca.lifecyclecallbacks.LifecycleCallbacksSupportApplication.java

public static LifecycleCallbacksSupportApplication applicationOf(Context context) {
    if (context instanceof Activity) {
        Activity activity = (Activity) context;
        Application app = activity.getApplication();
        if (app instanceof LifecycleCallbacksSupportApplication) {
            return (LifecycleCallbacksSupportApplication) app;
        }//  w  ww.j  av  a2s.c  o  m
    }

    if (context instanceof Service) {
        Service service = (Service) context;
        Application app = service.getApplication();
        if (app instanceof LifecycleCallbacksSupportApplication) {
            return (LifecycleCallbacksSupportApplication) app;
        }
    }

    Context appContext = context.getApplicationContext();
    if (appContext instanceof LifecycleCallbacksSupportApplication) {
        return (LifecycleCallbacksSupportApplication) appContext;
    }

    if (context instanceof ContextWrapper) {
        Context base = ((ContextWrapper) context).getBaseContext();

        if (base != null) {
            if (base instanceof LifecycleCallbacksSupportApplication) {
                return (LifecycleCallbacksSupportApplication) base;
            }

            Context baseAppContext = base.getApplicationContext();
            if (appContext instanceof LifecycleCallbacksSupportApplication) {
                return (LifecycleCallbacksSupportApplication) baseAppContext;
            }
        }
    }

    return null;
}

From source file:disono.webmons.com.utilities.sensor.GeoLocation.GPS.java

public GPS(Activity activity) {
    this.application = activity.getApplication();
}

From source file:com.emartynov.android.app.urlsetter.android.ui.fragment.EnterShortenedUrlFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    ((UrlApplication) activity.getApplication()).inject(this);
}

From source file:eu.inmite.apps.smsjizdenka.framework.fragment.BaseFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = activity.getApplicationContext();
    mApp = (App) activity.getApplication();
}

From source file:io.teak.sdk.Teak.java

private static void cleanup(Activity activity) {
    if (Teak.appStore != null) {
        Teak.appStore.dispose();//from  w  ww  . ja va2s  .c  om
    }

    RemoteConfiguration.removeEventListener(Teak.remoteConfigurationEventListener);
    Session.removeEventListener(Teak.sessionEventListener);

    if (Teak.facebookAccessTokenBroadcast != null) {
        Teak.facebookAccessTokenBroadcast.unregister(activity.getApplicationContext());
    }

    activity.getApplication().unregisterActivityLifecycleCallbacks(Teak.lifecycleCallbacks);
}

From source file:com.github.kanata3249.ffxieq.android.FFXIEQFragment.java

public void setCharacterID(long characterID) {
    Activity activity;

    activity = getActivity();//from  w w w .  j av  a 2 s .  co m
    ((FFXIEQApplication) activity.getApplication()).setCharacterID(characterID);
}

From source file:com.github.kanata3249.ffxieq.android.FFXIEQFragment.java

public void setCharacterIDToCompare(long characterID) {
    Activity activity;

    activity = getActivity();//w w w. j a  va 2  s  . com
    ((FFXIEQApplication) activity.getApplication()).setCharacterIDToCompare(characterID);
}

From source file:com.github.kanata3249.ffxieq.android.FFXIEQFragment.java

public void setFFXICharacter(FFXICharacter charInfo) {
    Activity activity;

    activity = getActivity();/*from  www. java  2s. co m*/
    ((FFXIEQApplication) activity.getApplication()).setFFXICharacter(charInfo);
}

From source file:com.github.kanata3249.ffxieq.android.FFXIEQFragment.java

public void setFFXICharacterToCompare(FFXICharacter charInfo) {
    Activity activity;

    activity = getActivity();//w  w w  .j  av a  2 s .  c o  m
    ((FFXIEQApplication) activity.getApplication()).setFFXICharacterToCompare(charInfo);
}

From source file:org.jboss.aerogear.todo.fragments.ProjectFormFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    application = (ToDoApplication) activity.getApplication();
    pipe = application.getPipeline().get("projects", this, application);
}