Beispiel #1
0
 /**
  * 根据服务器给过来的url启动Activity
  *
  * @param context
  * @param url
  */
 public static void startActivity(Context context, String url) {
   if (!TextUtils.isEmpty(url)) {
     Intent intent;
     if (url.contains(SCHEME)) {
       // 跳转内部页面
       // 事件统计
       String event = Uri.parse(url).getQueryParameter("event");
       if (!TextUtils.isEmpty(event)) {
         //                    UmengClickAgent.onEvent(context, event);
       }
       intent = SchemeUtil.getIntent(context, url);
     } else {
       if (URLUtil.isValidUrl(url)) {
         intent =
             new Intent(
                 SystemUtil.getApplicationPackageName(context) + BaseConstant.ACTION_WEB_VIEW);
         intent.putExtra(WebViewFragment.EXTRA_URL, url);
       } else {
         intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
       }
     }
     if (!(context instanceof Activity)) {
       intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     }
     try {
       context.startActivity(intent);
     } catch (ActivityNotFoundException e) { // // TODO: 跳转到首页
       //                context.startActivity(new Intent(Intent.ACTION_VIEW,
       // Uri.parse(getUri(context, R.string.path_main))));
       //                context.startActivity(new
       // Intent(SystemUtil.getApplicationPackageName(context) + BaseConstant.ACTION_MAIN));
       //                LogUtils.e("bacy->" + e);
     }
   }
 }
 private AndroidBug5497Workaround(final Activity activity) {
   mChildOfContent = ((FrameLayout) activity.findViewById(android.R.id.content)).getChildAt(0);
   isTintStatusBarEnable = SystemUtil.isTintStatusBarAvailable(activity);
   mChildOfContent
       .getViewTreeObserver()
       .addOnGlobalLayoutListener(
           new ViewTreeObserver.OnGlobalLayoutListener() {
             public void onGlobalLayout() {
               // 无语
               if (activity instanceof CommonActivity) {
                 if (((CommonActivity) activity).mIsResume || isKeybordShow) {
                   possiblyResizeChildOfContent();
                 }
               } else {
                 possiblyResizeChildOfContent();
               }
             }
           });
   //        navigationBarHeight = SystemUtil.getNavigationBarHeight(activity);
   frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
   //        bottomPadding = mChildOfContent.getPaddingBottom();
   //        mChildOfContent.setPadding(0,0,0,bottomPadding + (ApiCompatibleUtil.hasLollipop() ?
   // navigationBarHeight : 0));
 }
Beispiel #3
0
 public static String getAppName(Context context) {
   String packageName = SystemUtil.getApplicationPackageName(context);
   return packageName.substring(packageName.lastIndexOf(".") + 1);
 }