如何获取app-activity
发布网友
发布时间:2023-07-11 13:30
我来回答
共2个回答
热心网友
时间:2024-01-19 20:45
工具/原料:
app
android手机
数据线
1.需要配置好android的开发环境后,打开cmd命令窗口
2.在命令窗口中输入,adb logcat>D:/log.log,输入D盘下
3.运行手机上app应用程序,需要获取到app应用程序
4.然后停止运行获取手机上logcat的文件,停止是直接按Ctrl+c
5.打开输出的文件
6.通过抓取到log的日志,找到相应activity的应用程序。
热心网友
时间:2024-01-19 20:45
01.public class MainActivity extends Activity {
02.
03. ArrayList<String> list;
04. private List<ResolveInfo> mApps;
05. private ResolveInfo info;
06.
07. @Override
08. public void onCreate(Bundle savedInstanceState) {
09. super.onCreate(savedInstanceState);
10. setContentView(R.layout.activity_main);
11. Button btn = (Button) findViewById(R.id.btn);
12. ListView listView = (ListView) findViewById(R.id.listView);
13. list = new ArrayList<String>();
14. getList();
15. ArrayAdapter<String> mAdapter = new ArrayAdapter<String>(
16. MainActivity.this, android.R.layout.simple_list_item_1, list);
17. listView.setAdapter(mAdapter);
18. btn.setOnClickListener(new OnClickListener() {
19.
20. @Override
21. public void onClick(View v) {
22. Intent intent = new Intent();
23. ComponentName comp = new ComponentName(
24. "com.android.mmreader362",
25. "com.android.mmreader362.mmreader");
26. intent.setComponent(comp);
27. intent.setAction("android.intent.action.MAIN");
28. startActivity(intent);
29. }
30. });
31. }
32.
33. private void getList() {
34. list.clear();
35. Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
36. mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
37. mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
38. for (int i = 0; i < mApps.size(); i++) {
39. info = mApps.get(i);
40. String appLabel = info.loadLabel(getPackageManager()).toString();
41. String packagename = info.activityInfo.packageName;
42. String appname = info.activityInfo.name;
43. list.add("appLabel:" + appLabel + " || packagename:" + packagename
44. + " || appname:" + appname);
45. }
46. }
47.
48.}