开发者

Process ID of an Activity in android?

开发者 https://www.devze.com 2023-02-22 16:09 出处:网络
Can i get the process Id of an messaging activity? and also using this can i start that partic开发者_开发问答ular activity.You must be looking for Messaging Intent not process id.

Can i get the process Id of an messaging activity? and also using this can i start that partic开发者_开发问答ular activity.


You must be looking for Messaging Intent not process id.

Eg: startActivity(com.android.mms)


One solution that isn't pretty is to use Activity manager and go through all the Running app processes searching for that messaging app.

ActivityManager manager = (ActivityManager) context
                .getSystemService(Context.ACTIVITY_SERVICE);
        List<ActivityManager.RunningAppProcessInfo> processes = manager
                .getRunningAppProcesses();

        for (RunningAppProcessInfo process : processes) {
                String name = process.processName;
                if (name.contains(MESSAGING_APP_NAME) {
                    return process.pid;
                }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号