本文介绍了React Native 如何获取“getPackageManager()";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你知道如何在 react-native 中获取 getPackageManager() (for java) 的访问权限吗?我到处搜索,但我只发现 getPackageManager() 有一些错误......我需要这个来知道我的应用程序是从 Play 商店还是通过其他方法下载的.(我不能在我的帖子开头打招呼,我很礼貌:))
do you know how to get acces to getPackageManager() (for java) in react-native please? I searched everywhere but I only found some errors with getPackageManager()... I need this to know if my app has been downloaded from the Play Store or by other method. (I can't say Hi at the beginning of my post, I'm polite normaly:))
谢谢
推荐答案
您可以使用 React Native 应用程序上下文并从那里获取包管理器.
You can use the react native application context and get the package manager from there.
PackageManager manager = reactContext.getPackageManager();
或者只是从当前活动中获取
or just get it from the current activity
Activity currentActivity = getCurrentActivity();
PackageManager manager = currentActivity.getPackageManager();
这篇关于React Native 如何获取“getPackageManager()";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!