Android adb shell dumpsys activity intents 理解

adb shell dumpsys activity

用来查看当前运行时,activity的状态信息。

adb shell dumpsys activity 包含信息项

通过adb shell dumpsys activity | findstr “ACTIVITY MANAGER” ,打印的信息如下:

Android adb shell dumpsys activity intents 理解_第1张图片

ACTIVITY MANAGER PENDING INTENTS (dumpsys activity intents)
ACTIVITY MANAGER BROADCAST STATE (dumpsys activity broadcasts)
ACTIVITY MANAGER CONTENT PROVIDERS (dumpsys activity providers)
ACTIVITY MANAGER URI PERMISSIONS (dumpsys activity permissions)
ACTIVITY MANAGER SERVICES (dumpsys activity services)
ACTIVITY MANAGER RECENT TASKS (dumpsys activity recents)
ACTIVITY MANAGER ACTIVITIES (dumpsys activity activities)
ACTIVITY MANAGER RUNNING PROCESSES (dumpsys activity processes)

上面就是包含的信息项。
我们可以通过 adb shell dumpsys activity intents 来单独查看intents项,同样 broadcasts,providers,permissions 。。也可以单独查看。

dumpsys activity intents 理解

我们通过adb shell dumpsys activity 得到的信息,第一项就是有关intents的:

ACTIVITY MANAGER PENDING INTENTS (dumpsys activity intents)

  * PendingIntentRecord{a66ea76 com.google.android.partnersetup startService}

  * PendingIntentRecord{2aed646 com.android.deskclock startActivity}

  * PendingIntentRecord{9dec007 com.android.settings broadcastIntent}

  * PendingIntentRecord{f9c6b71 com.example.administrator.phoneinfo startActivity}

通过adb shell dumpsys activity intents 打印信息如下:

ACTIVITY MANAGER PENDING INTENTS (dumpsys activity intents)

  * PendingIntentRecord{a66ea76 com.google.android.partnersetup startService}

    uid=10064 packageName=com.google.android.partnersetup type=startService flags=0x0

    requestIntent=cmp=com.google.android.partnersetup/.RlzPingService

  * PendingIntentRecord{2aed646 com.android.deskclock startActivity}

    uid=1000 packageName=com.android.deskclock type=startActivity flags=0x0

    requestIntent=cmp=com.android.deskclock/.DeskClock

  * PendingIntentRecord{9dec007 com.android.settings broadcastIntent}

    uid=1000 packageName=com.android.settings type=broadcastIntent flags=0x0

    requestIntent=cat=[android.intent.category.ALTERNATIVE] dat=custom:2 cmp=com.android.settings/.widget.SettingsAppWidgetProvider

  * PendingIntentRecord{8a10bb com.example.administrator.phoneinfo startActivity}

    uid=10086 packageName=com.example.administrator.phoneinfo type=startActivity flags=0x0

    requestIntent=cmp=com.example.administrator.phoneinfo/.MainActivity

从上面看 adb shell dumpsys activity intents 能更详细的得到比 dumpsys activity 信息。

PendingIntentRecord

android系统中带处理的intent集合,包含notification widgetprovider 等中声明的PendingIntentRecord,如下:将自己的定义的intent 加入PendingIntentRecord中:

        NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
        Notification.Builder builder = new Notification.Builder(this);
        builder.setContentInfo("补充内容");
        builder.setContentText("主内容区");
        builder.setContentTitle("通知标题");
        builder.setSmallIcon(R.mipmap.ic_launcher);
        builder.setTicker("新消息");
        builder.setAutoCancel(true);
        builder.setWhen(System.currentTimeMillis());
        Intent intent1 = new Intent(this, DemoList.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent1, PendingIntent.FLAG_CANCEL_CURRENT);
        PendingIntent pendingIntent1 = PendingIntent.getActivity(this, 0, intent1, PendingIntent.FLAG_CANCEL_CURRENT);
        builder.setContentIntent(pendingIntent);
        Notification notification = builder.build();
        manager.notify(0, notification);

通过dumpsys activity intents 发现,上面添加的intent已经在打印信息中:

  * PendingIntentRecord{8a10bb com.example.administrator.phoneinfo startActivity}

    uid=10086 packageName=com.example.administrator.phoneinfo type=startActivity flags=0x0

    requestIntent=cmp=com.example.administrator.phoneinfo/.MainActivity

上面信息包括:包名,uid,启动类型(activity service broadcast),启动目标类。

你可能感兴趣的:(Android,android系统)