【FAQ】【JAVA UI】HarmonyOS 如何获取uid和pid

 【问题描述】

鸿蒙中怎么样可以获取Uid和Pid

 

【解决方案】

 try {
            BundleInfo bundleInfo= getContext().getBundleManager().getBundleInfo(getBundleName(),IBundleManager.GET_BUNDLE_DEFAULT);
            int uid=bundleInfo.uid;
            System.err.println("#######uid====>>"+uid);
           int pid= getContext().getProcessInfo().getPid();
           System.err.println("#######pid====>>"+pid);
        }catch (Exception e){
            e.printStackTrace();
        }

【运行效果】

cke_1449.png

欲了解更多更全技术文章,欢迎访问https://developer.huawei.com/consumer/cn/forum/?ha_source=zzh

{{o.name}}
{{m.name}}

猜你喜欢

转载自my.oschina.net/u/4478396/blog/5570394