日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

在Activity启动过程中如何任务栈的栈顶是否是将要启动的Activity的实例

發(fā)布時(shí)間:2024/7/5 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在Activity启动过程中如何任务栈的栈顶是否是将要启动的Activity的实例 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我們?cè)贏ctivityStack類(lèi)中可以看到某個(gè)方法用于返回當(dāng)前任務(wù)棧頂端的ActivityRecord對(duì)象,如果棧是空的,就返回null,ActivityRecord用于代表在歷史任務(wù)棧中的一個(gè)Activity對(duì)象的信息。

/*** Returns the top activity in any existing task matching the given* Intent. Returns null if no such task is found.*/private ActivityRecord findTaskLocked(Intent intent, ActivityInfo info) {ComponentName cls = intent.getComponent();if (info.targetActivity != null) {cls = new ComponentName(info.packageName, info.targetActivity);}TaskRecord cp = null;final int N = mHistory.size();for (int i=(N-1); i>=0; i--) {ActivityRecord r = (ActivityRecord)mHistory.get(i);if (!r.finishing && r.task != cp&& r.launchMode != ActivityInfo.LAUNCH_SINGLE_INSTANCE) {cp = r.task;//Slog.i(TAG, "Comparing existing cls=" + r.task.intent.getComponent().flattenToShortString()// + "/aff=" + r.task.affinity + " to new cls="// + intent.getComponent().flattenToShortString() + "/aff=" + taskAffinity);if (r.task.affinity != null) {if (r.task.affinity.equals(info.taskAffinity)) {//Slog.i(TAG, "Found matching affinity!");return r;}} else if (r.task.intent != null&& r.task.intent.getComponent().equals(cls)) {//Slog.i(TAG, "Found matching class!");//dump();//Slog.i(TAG, "For Intent " + intent + " bringing to top: " + r.intent);return r;} else if (r.task.affinityIntent != null&& r.task.affinityIntent.getComponent().equals(cls)) {//Slog.i(TAG, "Found matching class!");//dump();//Slog.i(TAG, "For Intent " + intent + " bringing to top: " + r.intent);return r;}}}return null;

貼一下ActivityRecord類(lèi)的信息:


/*** An entry in the history stack, representing an activity.*/ class ActivityRecord extends IApplicationToken.Stub {final ActivityManagerService service; // ownerfinal ActivityStack stack; // ownerfinal ActivityInfo info; // all about mefinal int launchedFromUid; // always the uid who started the activity.final Intent intent; // the original intent that generated usfinal ComponentName realActivity; // the intent component, or target of an alias.final String shortComponentName; // the short component name of the intentfinal String resolvedType; // as per original caller;final String packageName; // the package implementing intent's componentfinal String processName; // process where this component wants to runfinal String taskAffinity; // as per ActivityInfo.taskAffinityfinal boolean stateNotNeeded; // As per ActivityInfo.flagsfinal boolean fullscreen; // covers the full screen?final boolean componentSpecified; // did caller specifiy an explicit component?final boolean isHomeActivity; // do we consider this to be a home activity?final String baseDir; // where activity source (resources etc) locatedfinal String resDir; // where public activity source (public resources etc) locatedfinal String dataDir; // where activity data should goCharSequence nonLocalizedLabel; // the label information from the package mgr.int labelRes; // the label information from the package mgr.int icon; // resource identifier of activity's icon.int theme; // resource identifier of activity's theme.TaskRecord task; // the task this is in.long launchTime; // when we starting launching this activitylong startTime; // last time this activity was startedlong cpuTimeAtResume; // the cpu time of host process at the time of resuming activityConfiguration configuration; // configuration activity was last running inActivityRecord resultTo; // who started this entry, so will get our replyfinal String resultWho; // additional identifier for use by resultTo.final int requestCode; // code given by requester (resultTo)ArrayList results; // pending ActivityResult objs we have receivedHashSet<WeakReference<PendingIntentRecord>> pendingResults; // all pending intents for this actArrayList newIntents; // any pending new intents for single-top modeHashSet<ConnectionRecord> connections; // All ConnectionRecord we holdUriPermissionOwner uriPermissions; // current special URI access perms.ProcessRecord app; // if non-null, hosting applicationBitmap thumbnail; // icon representation of paused screenCharSequence description; // textual description of paused screenActivityState state; // current state we are inBundle icicle; // last saved activity stateboolean frontOfTask; // is this the root activity of its task?boolean launchFailed; // set if a launched failed, to abort on 2nd tryboolean haveState; // have we gotten the last activity state?boolean stopped; // is activity pause finished?boolean delayedResume; // not yet resumed because of stopped app switches?boolean finishing; // activity in pending finish list?boolean configDestroy; // need to destroy due to config change?int configChangeFlags; // which config values have changedboolean keysPaused; // has key dispatching been paused for it?boolean inHistory; // are we in the history stack?int launchMode; // the launch mode activity attribute.boolean visible; // does this activity's window need to be shown?boolean waitingVisible; // true if waiting for a new act to become visboolean nowVisible; // is this activity's window visible?boolean thumbnailNeeded;// has someone requested a thumbnail?boolean idle; // has the activity gone idle?boolean hasBeenLaunched;// has this activity ever been launched?boolean frozenBeforeDestroy;// has been frozen but not yet destroyed.String stringName; // for caching of toString().




總結(jié)

以上是生活随笔為你收集整理的在Activity启动过程中如何任务栈的栈顶是否是将要启动的Activity的实例的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。