Example usage for android.app Activity getParent

List of usage examples for android.app Activity getParent

Introduction

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

Prototype

public final Activity getParent() 

Source Link

Document

Return the parent activity if this view is an embedded child.

Usage

From source file:Main.java

public static Activity getRootContext(Activity activity) {
    while (activity.getParent() != null) {
        activity = activity.getParent();
    }//from   w  w w  . ja v a 2  s .c  om
    return activity;
}

From source file:Main.java

public static Activity modifyDialogContext(Activity cxt) {
    Activity parent = cxt.getParent();
    if (parent != null) {
        return parent;
    } else {//w  ww . ja  va  2s .  c  o m
        return cxt;
    }
}

From source file:Main.java

public static void finishWithoutResult(Activity context) {
    Activity parentActivity = context.getParent();
    context.finish();/*from ww  w  .  j a  v a2s  .  c  o  m*/
    if (parentActivity != null) {
        parentActivity.overridePendingTransition(0, android.R.anim.slide_out_right);
    } else {
        context.overridePendingTransition(0, android.R.anim.slide_out_right);
    }
}

From source file:Main.java

public static void goToStatistics(Activity activity) {
    TabActivity tabActivity = (TabActivity) activity.getParent();
    tabActivity.getTabHost().setCurrentTab(3);
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static void goToExtendedStatistics(Activity activity) {
    TabActivity tabActivity = (TabActivity) activity.getParent();
    tabActivity.getTabHost().setCurrentTab(5);
}

From source file:Main.java

public static void GoToStoreView(Activity activity) {

    TabActivity tabActivity = (TabActivity) activity.getParent();
    tabActivity.getTabHost().setCurrentTab(1);

}

From source file:Main.java

public static void finishWithResultCode(Activity context, int resultCode) {
    Activity parentActivity = context.getParent();
    context.setResult(resultCode);//from  w  w w  .  j  a v  a  2s. c om
    context.finish();
    if (parentActivity != null) {
        parentActivity.overridePendingTransition(0, android.R.anim.slide_out_right);
    } else {
        context.overridePendingTransition(0, android.R.anim.slide_out_right);
    }
}

From source file:Main.java

public static final Activity getRoot(Activity activity) {
    Activity ctx = activity;
    Activity parent;//from  w ww.  ja va 2  s  . c  om

    while ((parent = ctx.getParent()) != null) {
        ctx = parent;
    }

    return ctx;
}

From source file:Main.java

public static String getBreadcrumbs(final Activity activity) {
    Activity currentActivity = activity;
    ArrayList<String> breadcrumbs = new ArrayList<>();

    while (currentActivity != null) {
        breadcrumbs.add(currentActivity.getTitle().toString());
        currentActivity = currentActivity.getParent();
    }//  w  w w. j av a 2s.  co  m
    return joinSlash(breadcrumbs);
}

From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java

public static ServiceToken bindToService(Activity context, ServiceConnection callback) {
    Activity realActivity = context.getParent();
    if (realActivity == null) {
        realActivity = context;/*  ww  w . j  a va  2s  .  co m*/
    }
    ContextWrapper cw = new ContextWrapper(realActivity);
    cw.startService(new Intent(cw, MediaPlaybackService.class));
    ServiceBinder sb = new ServiceBinder(callback);
    if (cw.bindService((new Intent()).setClass(cw, MediaPlaybackService.class), sb, 0)) {
        sConnectionMap.put(cw, sb);
        return new ServiceToken(cw);
    }
    Log.e("Music", "Failed to bind to service");
    return null;
}