public static Activity getActivityOfView(Context context, View view) {
        Activity activity = null;
        try {
            if (context != null) {
                if (context instanceof Activity) {
                    activity = (Activity) context;
                } else if (context instanceof ContextWrapper) {
                    while (!(context instanceof Activity) && context instanceof ContextWrapper) {
                        context = ((ContextWrapper) context).getBaseContext();
                    }
                    if (context instanceof Activity) {
                        activity = (Activity) context;
                    }
                }

                if (activity == null && view != null) {
                    Object object = view.getTag(R.id.sensors_analytics_tag_view_activity);
                    if (object != null) {
                        if (object instanceof Activity) {
                            activity = (Activity) object;
                        }
                    }
                }
            }
        } catch (Exception e) {
            SALog.printStackTrace(e);
        }
        return activity;
    }
@Test
    public void getActivityOfView() {
        TextView textView1 = new TextView(mApplication);
        textView1.setText("child1");
        Assert.assertNull(SAViewUtils.getActivityOfView(mApplication, textView1));
    }