> 文档中心 > 【FAQ】【JAVA UI】HarmonyOS 如何获取uid和pid

【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

强国军事网