{"id":187,"date":"2024-09-20T21:40:15","date_gmt":"2024-09-20T13:40:15","guid":{"rendered":"https:\/\/newstrong.xyz\/?p=187"},"modified":"2024-09-20T21:40:15","modified_gmt":"2024-09-20T13:40:15","slug":"android%e4%b8%ad%e8%bf%9b%e7%a8%8b%e7%9b%b8%e5%85%b3%e4%bf%a1%e6%81%af%e8%8e%b7%e5%8f%96%ef%bc%8cpid%ef%bc%8c%e8%bf%9b%e7%a8%8b%e5%90%8d-2","status":"publish","type":"post","link":"https:\/\/newstrong.top\/index.php\/2024\/09\/20\/android%e4%b8%ad%e8%bf%9b%e7%a8%8b%e7%9b%b8%e5%85%b3%e4%bf%a1%e6%81%af%e8%8e%b7%e5%8f%96%ef%bc%8cpid%ef%bc%8c%e8%bf%9b%e7%a8%8b%e5%90%8d-2\/","title":{"rendered":"Android\u4e2d\u8fdb\u7a0b\u76f8\u5173\u4fe1\u606f\u83b7\u53d6\uff0cpid\uff0c\u8fdb\u7a0b\u540d"},"content":{"rendered":"<p>1. \u83b7\u53d6pid<\/p>\n<\/p>\n<pre><code class=\"language-java\">int pid = android.os.Process.myPid();<\/code><\/pre>\n<p> 2. \u83b7\u53d6\u8fdb\u7a0b\u540d\u53ca\u5176\u4ed6\u4fe1\u606f <\/p>\n<\/p>\n<pre><code class=\"language-java\">ActivityManager mActivityManager = (ActivityManager) getContext().getSystemService(Context.ACTIVITY_SERVICE);\nfor (ActivityManager.RunningAppProcessInfo appProcess : mActivityManager\n        .getRunningAppProcesses()) {\n    if (appProcess.pid == pid) {\n        procName = appProcess.processName;\n    }\n}<\/code><\/pre>\n<p> appProcess\u4e2d\u53ef\u4ee5\u83b7\u53d6\u4e00\u4e9b\u8fdb\u7a0b\u76f8\u5173\u7684\u4fe1\u606f\uff0c\u5982\uff1a <\/p>\n<pre><code class=\"language-java\">        \/**\n         * The name of the process that this object is associated with\n         *\/\n        public String processName;\n\n        \/**\n         * The pid of this process; 0 if none\n         *\/\n        public int pid;\n\n        \/**\n         * The user id of this process.\n         *\/\n        public int uid;\n\n        \/**\n         * All packages that have been loaded into the process.\n    <\/code><\/pre>\n<p>\u6587\u7ae0\u6765\u6e90\u4e8e\u4e92\u8054\u7f51:<a href=\"https:\/\/blog.csdn.net\/archer_zoro\/article\/details\/52087835\" target=\"_blank\" rel=\"noopener\">Android\u4e2d\u8fdb\u7a0b\u76f8\u5173\u4fe1\u606f\u83b7\u53d6\uff0cpid\uff0c\u8fdb\u7a0b\u540d<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u83b7\u53d6pid int pid = android.os.Process.myPid(); 2. \u83b7\u53d6\u8fdb\u7a0b\u540d&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":71,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":0,"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/media\/71"}],"wp:attachment":[{"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/newstrong.top\/index.php\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}