本文整理匯總了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);
}
}