当前位置: 首页>>代码示例>>Java>>正文


Java Activity.isDestroyed方法代码示例

本文整理汇总了Java中android.app.Activity.isDestroyed方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.isDestroyed方法的具体用法?Java Activity.isDestroyed怎么用?Java Activity.isDestroyed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.isDestroyed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContext

import android.app.Activity; //导入方法依赖的package包/类
/**
 * get the activity which is owned. if the activity is finish or destroyed or recycled. it return null.
 * @return the activity, may be null.
 */
public Context getContext(){
    final Context t = mWeakActivity.get();
    if(t != null && t instanceof Activity) {
        final Activity ac = (Activity) t;
        if (ac.isFinishing()) {
            return null;
        }
        if (Build.VERSION.SDK_INT >= 17 && ac.isDestroyed()) {
            Log.w("WeakActivityOwner","getActivity(): memory leaked ? t = "
                    + t.getClass().getName());
            return null;
        }
        return t;
    }
    return null;
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:21,代码来源:WeakContextOwner.java

示例2: buildDialog

import android.app.Activity; //导入方法依赖的package包/类
public static Dialog buildDialog(Context context, boolean cancleable, boolean outsideTouchable) {


        if (context instanceof Activity){//todo keycode
            Activity activity = (Activity) context;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                if (activity.isDestroyed()){
                    context = StyledDialog.context;
                }
            }
        }

        Dialog dialog = new Dialog(context);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setCancelable(cancleable);
        dialog.setCanceledOnTouchOutside(outsideTouchable);
        return dialog;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:Tool.java

示例3: secureSettings

import android.app.Activity; //导入方法依赖的package包/类
public void secureSettings(Activity activity, final Context appContext, Exception e, String page) { //exception function for a Secure Settings problem
    Log.e(page, e.getMessage()); //log the error
    e.printStackTrace();

    if (!activity.isDestroyed()) {
        new AlertDialog.Builder(activity) //show a dialog with the error and prompt user to set up permissions again
                .setIcon(alertRed)
                .setTitle(Html.fromHtml("<font color='#ff0000'>" + activity.getResources().getText(R.string.error) + "</font>"))
                .setMessage(activity.getResources().getText(R.string.perms_not_set) + "\n\n\"" + e.getMessage() + "\"\n\n" + activity.getResources().getText(R.string.prompt_setup))
                .setPositiveButton(activity.getResources().getText(R.string.yes), new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Intent intent = new Intent(appContext, SetupActivity.class);
                        intent.addFlags(intent.FLAG_ACTIVITY_NEW_TASK);
                        appContext.startActivity(intent);
                    }
                })
                .setNegativeButton(activity.getResources().getText(R.string.no), null)
                .show();
    }
}
 
开发者ID:zacharee,项目名称:SystemUITuner2,代码行数:22,代码来源:Exceptions.java

示例4: finishActivitySync

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
static public void finishActivitySync(Activity activity, Instrumentation instrumentation, boolean doFinish)
{
    if (doFinish)
        activity.finish();
    //give activity one minute to finish
    long currentTime = System.currentTimeMillis();
    boolean finishTimeout = false;
    int activityHash = activity.hashCode();
    boolean isDestroyed = false;

    while (!isDestroyed && !finishTimeout) {
        instrumentation.waitForIdleSync();
        finishTimeout = (System.currentTimeMillis() - currentTime) > 140000;

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            isDestroyed = activity.isDestroyed();
        }else {
            isDestroyed = (Boolean)callMethod(null, activity.getWindow(), "isDestroyed", null);
        }
    }

    if (finishTimeout) {
        WebtrekkLogging.log("finishActivitySync: finished by timeout. Hash:" + activityHash);
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:27,代码来源:WebtrekkBaseSDKTest.java

示例5: isActivityDestoryed

import android.app.Activity; //导入方法依赖的package包/类
public static boolean isActivityDestoryed(Activity activity) {
    if (activity == null) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return activity.isDestroyed();
    } else {
        return activity.isFinishing();
    }
}
 
开发者ID:myl2ning,项目名称:fragmentnav,代码行数:11,代码来源:Androids.java

示例6: isActivityFinish

import android.app.Activity; //导入方法依赖的package包/类
public boolean isActivityFinish(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        return activity.isDestroyed() || activity.isFinishing();
    } else {
        return activity.isFinishing();
    }
}
 
开发者ID:chendongMarch,项目名称:uikit,代码行数:8,代码来源:UIManager.java

示例7: getCurrentActivity

import android.app.Activity; //导入方法依赖的package包/类
public Activity getCurrentActivity() {
    Activity currentActivity = null;
    if (sCurrentActivityWeakRef != null) {
        currentActivity = sCurrentActivityWeakRef.get();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if(currentActivity ==null || currentActivity.isDestroyed()){
                currentActivity = null;
            }
        }
    }
    return currentActivity;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:MyActyManager.java

示例8: fixContext

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 混合上下文
 */
public static BuildBean fixContext(BuildBean bean) {
    if (bean.mContext == null) {
        bean.mContext = DialogUIUtils.appContext;
    } else if (bean.mContext instanceof Activity) {
        Activity activity = (Activity) bean.mContext;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (activity.isDestroyed()) {
                bean.mContext = DialogUIUtils.appContext;
            }
        }
    }
    return bean;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:ToolUtils.java

示例9: setDialogStyle

import android.app.Activity; //导入方法依赖的package包/类
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
    if (dialog == null) {
        return;
    }
    Window window = dialog.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    window.setGravity(bean.gravity);
    WindowManager.LayoutParams wl = window.getAttributes();
    // 以下这两句是为了保证按钮可以水平满屏
    int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
    if (bean.type != DialogConfig.TYPE_MD_LOADING) {
        wl.width = (int) (width * 0.94);  // todo keycode to keep gap
    } else {
        wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    }
    wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;  //TODO  一般情况下为wrapcontent,最大值为height*0.9
    if (measuredHeight > height) {
        wl.height = height;
    }
    if (context instanceof Activity) {
        Activity activity1 = (Activity) context;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (activity1.isDestroyed()) {
                context = DialogUIUtils.appContext;
            }
        }
    } else {
        wl.type = WindowManager.LayoutParams.TYPE_TOAST;
        //todo keycode to improve window level,同时要让它的后面半透明背景也拦截事件,不要传递到下面去
        //todo 单例化,不然连续弹出两次,只能关掉第二次的
    }
    dialog.onWindowAttributesChanged(wl);

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:36,代码来源:ToolUtils.java

示例10: cancelDialog

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 退出加载提示
 */

private void cancelDialog() {
    if (dialog != null && dialog.isShowing()) {
        Activity activity = dialog.getOwnerActivity();
        if (activity==null||activity.isDestroyed()||activity.isFinishing()){
            return;
        }

        dialog.dismiss();
    }
}
 
开发者ID:AlpacaNotSheep,项目名称:hybrid,代码行数:15,代码来源:IndexWebActivityNew.java

示例11: setDialogStyle

import android.app.Activity; //导入方法依赖的package包/类
public static void setDialogStyle(Context context, Dialog dialog, int measuredHeight, BuildBean bean) {
    if (dialog == null) {
        return;
    }
    Window window = dialog.getWindow();
    window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    window.setGravity(bean.gravity);
    WindowManager.LayoutParams wl = window.getAttributes();
    // 以下这两句是为了保证按钮可以水平满屏
    int width = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getWidth();
    int height = (int) (((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getHeight() * 0.9);
    if (bean.type != CommonConfig.TYPE_MD_LOADING_VERTICAL) {
        wl.width = (int) (width * 0.94);  // todo keycode to keep gap
    } else {
        wl.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    }
    wl.height = ViewGroup.LayoutParams.WRAP_CONTENT;  //TODO  一般情况下为wrapcontent,最大值为height*0.9
    if (measuredHeight > height) {
        wl.height = height;
    }
    if (context instanceof Activity) {
        Activity activity1 = (Activity) context;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            if (activity1.isDestroyed()) {
                context = DialogUIUtils.appContext;
            }
        }
    } else {
        wl.type = WindowManager.LayoutParams.TYPE_TOAST;
        //todo keycode to improve window level,同时要让它的后面半透明背景也拦截事件,不要传递到下面去
        //todo 单例化,不然连续弹出两次,只能关掉第二次的
    }
    dialog.onWindowAttributesChanged(wl);

}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:36,代码来源:ToolUtils.java

示例12: showImpl

import android.app.Activity; //导入方法依赖的package包/类
@UiThread
private void showImpl(Params params) {
    if (mContext instanceof Activity) {
        Activity ac = ((Activity) mContext);
        if (ac.isFinishing()) {
            //ignore
            return;
        }
        if (Build.VERSION.SDK_INT >= 17 && ac.isDestroyed()) {
            //ignore
            return;
        }
    }
    if (params.start != null) {
        params.start.run();
    }

    if (mWindowView.getParent() != null) {
        mWM.removeView(mWindowView);
    }
    mShowing = true;
    //mWindowView.setY(-mWindowView.getMeasuredHeight());
    mWM.addView(mWindowView, mUsingConfig.wlp);

    //duration < 0, means until cancel.
    if (mUsingConfig.duration > 0) {
        mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_CANCEL, params),
                mUsingConfig.duration);
    }
}
 
开发者ID:LightSun,项目名称:android-util2,代码行数:31,代码来源:BaseWindow.java

示例13: canLoadImage

import android.app.Activity; //导入方法依赖的package包/类
public static boolean canLoadImage(Activity activity) {
    if (activity == null) {
        return true;
    }

    boolean destroyed = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 &&
            activity.isDestroyed();

    if (destroyed || activity.isFinishing()) {
        return false;
    }

    return true;
}
 
开发者ID:malijie,项目名称:PhotoPicker-master,代码行数:15,代码来源:AndroidLifecycleUtils.java

示例14: assertNotDestroyed

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static void assertNotDestroyed(Activity activity) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) {
    throw new IllegalArgumentException("You cannot start a load for a destroyed activity");
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:7,代码来源:RequestManagerRetriever.java

示例15: assertNotDestroyed

import android.app.Activity; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private static void assertNotDestroyed(Activity activity) {
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) {
		throw new IllegalArgumentException("You cannot start a load for a destroyed activity");
	}
}
 
开发者ID:myjoybar,项目名称:Android-lifecycle-listener,代码行数:7,代码来源:LifecycleManager.java


注:本文中的android.app.Activity.isDestroyed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。