本文整理汇总了Java中android.app.Activity.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.equals方法的具体用法?Java Activity.equals怎么用?Java Activity.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.equals方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPenultimateActivity
import android.app.Activity; //导入方法依赖的package包/类
/**
* 获取倒数第二个 Activity
*
* @return
*/
@Nullable
public Activity getPenultimateActivity(Activity currentActivity) {
Activity activity = null;
try {
if (mActivityStack.size() > 1) {
activity = mActivityStack.get(mActivityStack.size() - 2);
if (currentActivity.equals(activity)) {
int index = mActivityStack.indexOf(currentActivity);
if (index > 0) {
// 处理内存泄漏或最后一个 Activity 正在 finishing 的情况
activity = mActivityStack.get(index - 1);
} else if (mActivityStack.size() == 2) {
// 处理屏幕旋转后 mActivityStack 中顺序错乱
activity = mActivityStack.lastElement();
}
}
}
} catch (Exception e) {
}
return activity;
}
示例2: onActivityDestroyed
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onActivityDestroyed(Activity activity) {
Log.d(TAG, "onActivityDestroyed: " + activity);
if(activity.equals(currentActivity)){
currentActivity = null;
}
getModel().cleanObserverForActivity(activity);
}
示例3: findActivity
import android.app.Activity; //导入方法依赖的package包/类
private Activity findActivity(Activity activity) {
if (null == activity || null == mActivityList) {
return null;
}
for (Activity aty : mActivityList) {
if (null == aty) {
continue;
}
if (activity.equals(aty)) {
return aty;
}
}
return null;
}
示例4: finishOthers
import android.app.Activity; //导入方法依赖的package包/类
/**
* 结束除过当前Activity以外的其它Activity
*
* @param activity
*/
public void finishOthers(Activity activity) {
for (Activity act : activities) {
if (!act.equals(activity)) {
act.finish();
}
}
}
示例5: setTopActivityWeakRef
import android.app.Activity; //导入方法依赖的package包/类
private static void setTopActivityWeakRef(Activity activity) {
if (sTopActivityWeakRef == null || !activity.equals(sTopActivityWeakRef.get())) {
sTopActivityWeakRef = new WeakReference<>(activity);
}
}
示例6: setTopActivityWeakRef
import android.app.Activity; //导入方法依赖的package包/类
private static void setTopActivityWeakRef(Activity activity) {
if (sTopActivityWeakRef == null || !activity.equals(sTopActivityWeakRef.get())) {
sTopActivityWeakRef = new WeakReference<Activity>(activity);
}
}