작업의 활동 스택을 봅니다.
나는 여전히 플랫폼을 배우는 동안 간단한 안드로이드 응용 프로그램을 개발하기 시작했습니다.
ADT 플러그인 0.9.6과 함께 Eclipse IDE를 사용하고 있습니다.
Activity
작업과 관련된 스택 을 볼 수 있는지 알아야 합니까?
DDMS 도구 또는 다른 기술을 통해 어떤 방법이 있습니까?
본질적으로 필요한 것은 응용 프로그램이 예상대로 작동하는지 확인하기 위해 작업의 스택 활동을 볼 수 있어야합니다.
Intent
객체 에서 플래그를 사용 하고 <activity>
요소의 일부 속성을 통해 어느 정도 작업 동작을 제어 할 수 있다는 것을 알고 있습니다.
그러나 개발자가 Activity
스택을 곧바로 볼 수 있도록하는 일종의 도구 (특히 디버그 모드 등)가 있으면 좋을 것 입니다.
명령 행에서 다음을 사용할 수 있습니다. adb shell dumpsys activity
이것은 활동 관리자에게 현재 상태의 덤프를 인쇄하도록 요청합니다. 그 첫 번째 부분은 작업별로 구성된 전체 활동 기록입니다. 그 후에도 많은 것들이 인쇄되므로 원하는 것을 찾기 위해 약간 위로 스크롤해야 할 수도 있습니다.
다음은 출력의 예입니다 (정확한 내용은 플랫폼 버전에 따라 다름). 최상위 작업은 두 활동과의 접촉이고 그 뒤에는 하나의 활동과 실행기가 있음을 보여줍니다.
현재 활동 관리자 상태의 활동 : * TaskRecord {44d07218 # 4 android.task.contacts} clearOnBackground = true numActivities = 2 rootWasReset = true affinity = android.task.contacts intent = {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] flg = 0x10600000 cmp = com.android.contacts / .DialtactsActivity bnds = [125,640] [235,758]} origActivity = com.android.contacts / .DialtactsContactsEntryActivity realActivity = com.android.contacts / .DialtactsActivity lastActiveTime = 288203177 (14 초 동안 비활성) * Hist # 8 : HistoryRecord {44b87a30 com.android.contacts / .ViewContactActivity} packageName = com.android.contacts processName = android.process.acore launchFromUid = 10004 app = ProcessRecord {44c4f348 1168 : android.process.acore / 10004} 의도 {act = android.intent.action.VIEW dat = content : //com.android.contacts/contacts/lookup/144i148.144i461a29500afc8eeb/1927 cmp = com.android.contacts / .ViewContactActivity} frontOfTask = false task = TaskRecord {44d07218 # 4 android.task.contacts} taskAffinity = android.task.contacts realActivity = com.android.contacts / .ViewContactActivity base = / system / app / Contacts.apk / system / app / Contacts.apk data = / data / data / com.android.contacts labelRes = 0x7f090012 icon = 0x7f02006b 테마 = 0x7f0e0004 stateNotNeeded = 거짓 componentSpecified = false isHomeActivity = false configuration = {scale = 1.0 imsi = 310 / 4 loc = en_US touch = 3 keys = 2 / 1 / 2 nav = 2 / 2 orien = 1 layout = 34} resultTo = HistoryRecord {44d174d0 com.android.contacts / .DialtactsContactsEntryActivity} resultWho = 즐겨 찾기 resultCode = 2 launchFailed = false haveState = false 고드름 = 널 state = RESUMED stop = false delayedResume = false 마무리 = false keysPaused = 거짓 inHistory = true 지속적 = 거짓 launchMode = 0 fullscreen = true visible = true frozenBeforeDestroy = false thumbnailNeeded = false idle = true waitingVisible = false nowVisible = true * Hist # 7 : HistoryRecord {44d174d0 com.android.contacts / .DialtactsContactsEntryActivity} packageName = com.android.contacts processName = android.process.acore launchFromUid = 10004 app = ProcessRecord {44c4f348 1168 : android.process.acore / 10004} 의도 {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] flg = 0x10200000 cmp = com.android.contacts / .DialtactsContactsEntryActivity bnds = [125,640] [235,758]} frontOfTask = true task = TaskRecord {44d07218 # 4 android.task.contacts} taskAffinity = android.task.contacts realActivity = com.android.contacts / .DialtactsActivity base = / system / app / Contacts.apk / system / app / Contacts.apk data = / data / data / com.android.contacts labelRes = 0x7f090007 icon = 0x7f02006b 테마 = 0x7f0e0000 stateNotNeeded = 거짓 componentSpecified = true isHomeActivity = false configuration = {scale = 1.0 imsi = 310 / 4 loc = en_US touch = 3 keys = 2 / 1 / 2 nav = 2 / 2 orien = 1 layout = 34} launchFailed = false haveState = true icicle = 번들 [mParcelledData.dataSize = 4196] state = STOPPED 중지됨 = true 지연됨 재개 = false 마무리 = false keysPaused = 거짓 inHistory = true 지속적 = 거짓 launchMode = 2 fullscreen = true visible = false frozenBeforeDestroy = false thumbnailNeeded = false idle = true * TaskRecord {44c4ee90 # 2 com.android.launcher} clearOnBackground = true numActivities = 1 rootWasReset = true affinity = com.android.launcher intent = {act = android.intent.action.MAIN cat = [android.intent.category.HOME] flg = 0x10600000 cmp = com.android.launcher / .Launcher} realActivity = com.android.launcher / .Launcher lastActiveTime = 214734838 (73483 초 동안 비활성) * 히 스트 # 6 : HistoryRecord {44c4d988 com.android.launcher / .Launcher} packageName = com.android.launcher processName = android.process.acore launchFromUid = 0 app = ProcessRecord {44c4f348 1168 : android.process.acore / 10004} 의도 {act = android.intent.action.MAIN cat = [android.intent.category.HOME] flg = 0x10000000 cmp = com.android.launcher / .Launcher} frontOfTask = true task = TaskRecord {44c4ee90 # 2 com.android.launcher} taskAffinity = com.android.launcher realActivity = com.android.launcher / .Launcher base = / system / app / Launcher.apk / system / app / Launcher.apk data = / data / data / com.android.launcher labelRes = 0x7f0a0000 icon = 0x7f020015 테마 = 0x103005f stateNotNeeded = true componentSpecified = false isHomeActivity = true configuration = {scale = 1.0 imsi = 310 / 4 loc = en_US touch = 3 keys = 2 / 1 / 2 nav = 2 / 2 orien = 1 layout = 34} launchFailed = false haveState = true icicle = 번들 [mParcelledData.dataSize = 5964] state = STOPPED 중지됨 = true 지연됨 재개 = false 마무리 = false keysPaused = 거짓 inHistory = true 지속적 = 거짓 launchMode = 2 fullscreen = true visible = false frozenBeforeDestroy = false thumbnailNeeded = false idle = true
명령 행에서 다음 명령을 사용하여 시스템의 태스크 및 백 스택을 볼 수 있습니다.
adb shell dumpsys activity activities | sed -En -e '/Stack #/p' -e '/Running activities/,/Run #0/p'
또는 앱에서 모든 활동과 작업을 모니터링하고 Logcat에 실시간으로 출력 할 수있는 간단한 도구 인 TaskLogger 를 사용해 볼 수 있습니다.
나는 이것이 오래된 질문이라는 것을 알고 있지만이 기능은 이제 Android Studio에 구워졌습니다.
Then in the resulting text file, search for ACTIVITY
(all caps):
If you want to inspect the task stack of a specific package, the following command will do:
adb shell dumpsys activity activities | grep PACKAGE_NAME | grep Hist
I always check this part of long dump messages..
Running activities (most recent first):
TaskRecord{4307f828 #56 A com.demo.proj U 0}
Run #4: ActivityRecord{425a6838 com.demo.proj/com.demo.proj.Activity2}
Run #3: ActivityRecord{427dc860 com.demo.proj/com.demo.proj.Activity1}
Run #2: ActivityRecord{420cba18 com.demo.proj/com.demo.proj.MainActivity}
TaskRecord{430341d0 #2 A com.lge.launcher2 U 0}
Run #1: ActivityRecord{41e0af68 com.lge.launcher2/.Launcher}
TaskRecord{44e26ce0 #18 A com.lge.appbox.client U 0}
Run #0: ActivityRecord{41e9dbe8 com.lge.appbox.client/.AppBoxClient}
Note: Run #4 is the activity that you see now on the screen. :)
You can use the tool hierarchyviewer.bat. It is part of the android SDK. It only works with emulator though. But it is much more confortable and clearer.
Edit: I just found the Hierarchy Viewer within Eclipse! And it works with real devices as well. Just open the perspective Windows->Open Perspective-> Hierarchy View In the list you can see the all the connected devices and emulators and the activity stack. And in addition in the tree view you can see much more information about the view itself.
Edit: The Hierarchy Viewer will work only with developer devices. Production devices cannot do it for security reasons. For more information please take a look at following answer
For the list of recent tasks
adb shell dumpsys activity recents
For the list of Services running
adb shell dumpsys activity services
For the list of current Content Providers
adb shell dumpsys activity providers
For the list of Broadcast state
adb shell dumpsys activity broadcasts
For the list of Pending Intents
adb shell dumpsys activity intents
For the list of permissions
adb shell dumpsys activity permissions
Solution: 'adb shell dumpsys activity' does not work with TabActivity. When each tab item selected, corresponding activity will be launch. But when use 'adb shell dumpsys activity' It always return 'main' activity:
public class main extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
Log.e("xyz", "start main...............");
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, widgets.class);
spec = tabHost.newTabSpec("Widgets").setIndicator("Widgets", res.getDrawable(R.drawable.tab1)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, layouts.class);
spec = tabHost.newTabSpec("Layouts").setIndicator("Layouts",res.getDrawable(R.drawable.tab2)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, composite1.class);
spec = tabHost.newTabSpec("Composite").setIndicator("Composite",res.getDrawable(R.drawable.tab3)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, imageMedia.class);
spec = tabHost.newTabSpec("Image_Media").setIndicator("Image&Media",res.getDrawable(R.drawable.tab4)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, timeDate.class);
spec = tabHost.newTabSpec("Time_Date").setIndicator("Time&Date",res.getDrawable(R.drawable.tab5)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, transitions.class);
spec = tabHost.newTabSpec("Transitions").setIndicator("Transitions",res.getDrawable(R.drawable.tab6)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, advanced.class);
spec = tabHost.newTabSpec("Advanced").setIndicator("Advanced",res.getDrawable(R.drawable.tab7)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, others.class);
spec = tabHost.newTabSpec("Others").setIndicator("Others",res.getDrawable(R.drawable.tab8)).setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Dynamic.class);
spec = tabHost.newTabSpec("Dynamic").setIndicator("Dynamic",res.getDrawable(R.drawable.tab2)).setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}
참고URL : https://stackoverflow.com/questions/2442713/view-the-tasks-activity-stack
'Programming' 카테고리의 다른 글
열 값이 다른 모든 행을 선택하는 방법 (0) | 2020.06.28 |
---|---|
Antlr의 장점 (즉, lex / yacc / bison) (0) | 2020.06.28 |
아름다운 수프와 ID로 div와 그 내용 추출 (0) | 2020.06.28 |
줄거리 틱 수 감소 (0) | 2020.06.28 |
Xcode 9- "고정 너비 제한으로 인해 클리핑이 발생할 수 있음"및 기타 현지화 경고 (0) | 2020.06.28 |