本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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");
}
}
示例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");
}
}