Get the Activity of a context. This is typically used to determine the hosting activity of a
{@link View}

@param context The context
@return The Activity or throws an Exception if Activity couldnt be determined
773673
@NonNull public static Activity getActivity(@NonNull Context context) {
    if (context == null) {
      throw new NullPointerException("context == null");
    }
    if (context instanceof Activity) {
      return (Activity) context;
    }

    while (context instanceof ContextWrapper) {
      if (context instanceof Activity) {
        return (Activity) context;
      }
      context = ((ContextWrapper) context).getBaseContext();
    }
    throw new IllegalStateException("Could not find the surrounding Activity");
  }
1157884
public Context getContext() {
		if (context == null) {
			context = Model.getSingleton().getSession().getContext(this.contextId);
		}
		return context;
	}
626277
public static Context getApplicationContext() {
        com.ardikars.jxnet.context.Context context = com.ardikars.jxnet.context.Application.getApplicationContext();
        return new ApplicationContext(context);
    }
301769
public static void register(ActivityListener activityListener, Context context) {
    ListenableActivity activity = getListenableActivity(context);
    if (activity != null) {
      Listener listener = new Listener(activityListener);
      activity.addActivityListener(listener);
    }
  }
261027
public ApplicationContext getApplicationContext(final JobExecutionContext context) throws JobExecutionException {
        SchedulerContext schedulerContext;
        try {
            final Scheduler scheduler = context.getScheduler();
            schedulerContext = scheduler.getContext();
        } catch (SchedulerException e) {
        	logger.error("Unable to retrieve the scheduler context, cause : ", e);
            throw new JobExecutionException(e);
        }
        final ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_BEAN_NAME);
        return applicationContext;
    }
582423
public LRActivity getActivity(){
		LRActivity activity = new LRActivity(getResourceURL(), getSubmitter().getSubmitter(), getSubmitter().getSubmitterType(), getSubmitter().getSubmissionTOS(), getSubmitter().getSubmissionAttribution(), getSubmitter().getSigner());
		if (getActor() != null)
			activity.addActor("actor", getActor().getName(), getActor().getUrl(), null);
		activity.addVerb(getAction().getVerb(), null, null, null, null);
		if (this.action.getContextUrl() != null){
			activity.addContextToVerb("Widget", this.action.getContextUrl(), "Detail page");
		}
		activity.addContent(getAction().getContent());
		getAction().addMeasure(activity);
		activity.addObject(null, null, getResourceURL());
		return activity;
	}
252554
public static ActivityContext getActivityContext(HttpServlet servlet) {
        ServletContext servletContext = servlet.getServletContext();
        String attrName = STANDALONE_WEB_SERVICE_ATTRIBUTE_PREFIX + servlet.getServletName();
        ActivityContext activityContext = getActivityContext(servletContext, attrName);
        if (activityContext != null) {
            return activityContext;
        } else {
            return getActivityContext(servletContext);
        }
    }
920134
private static WebView createWebView(final Context context) {
        final WebView webView = new WebView(context);
        webView.getSettings().setSupportMultipleWindows(true);
        webView.setWebChromeClient(new WebChromeClient() {
            @Override
            public boolean onCreateWindow(final WebView view, final boolean isDialog, final boolean isUserGesture, final Message resultMsg) {
                final WebView.HitTestResult result = view.getHitTestResult();
                final String data = result.getExtra();
                if (data != null) {
                    final Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(data));
                    context.startActivity(browserIntent);
                }
                return false;
            }
        });
        return webView;
    }
738545
public static void startActivity(@NonNull Context context, @Nullable JSONArray jsonArray) {
        Intent intent = new Intent(context, JSONViewerActivity.class);
        Bundle bundle = new Bundle();
        if (jsonArray != null) {
            bundle.putString(JSON_ARRAY_STATE, jsonArray.toString());
        }
        intent.putExtras(bundle);
        context.startActivity(intent);
    }
809972
public static RxBleClient getRxBleClient(Context context) {
        SampleApplication application = (SampleApplication) context.getApplicationContext();
        return application.rxBleClient;
    }
581341
static CalligraphyActivityFactory get(Activity activity) {
        if (!(activity.getLayoutInflater() instanceof CalligraphyLayoutInflater)) {
            throw new RuntimeException("This activity does not wrap the Base Context! See CalligraphyContextWrapper.wrap(Context)");
        }
        return (CalligraphyActivityFactory) activity.getLayoutInflater();
    }
990515
public ActivityHandle getActivityHandle(Object arg0) {
        if (arg0 instanceof HttpClientActivityImpl) {
            HttpClientActivityHandle handle = new HttpClientActivityHandle(
                    ((HttpClientActivityImpl) arg0).getSessionId());
            if (activities.containsKey(handle)) {
                return handle;
            }
        }
        return null;
    }
1100494
@Activate
    protected void activate(ComponentContext context) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled())
            Tr.event(tc, "activate", context);
    }
199097
@Nullable static View getView(Context context, int resourceId, View view) {
    LayoutInflater inflater = LayoutInflater.from(context);
    if (view != null) {
      return view;
    }
    if (resourceId != INVALID) {
      view = inflater.inflate(resourceId, null);
    }
    return view;
  }
38529
protected static <T extends Annotation> T getAnnotationFromContext(InvocationContext context, Class<T> clazz) {
        T result = context.getMethod().getAnnotation(clazz);
        return result != null ? result : context.getTarget().getClass().getAnnotation(clazz);
    }
298503
public static String getTopActivityClassName(Context context) {
		ComponentName activity = getTopActivity(context);
		if (activity == null) {
			return null;
		}
		return activity.getClassName();
	}
1250308
public <T> T executeInApplicationContext(Callable<T> callable) throws Exception {
        ApplicationContext context = (ApplicationContext) getScopedContext(ApplicationScoped.class);
        boolean activatedByUs = false;
        try {
            if (!context.isActive()) {
                context.activate();
                activatedByUs = true;
            }
            return callable.call();
        } finally {
            if (activatedByUs && context.isActive()) {
                context.deactivate();
            }
        }
    }