[英]Titanium: Check if application installed on the device (android)
How i can check if application installed on android device (for eg by application id - com.foo.bar) ? 我如何检查Android设备上是否安装了应用程序(例如,通过应用程序ID - com.foo.bar)? Or, how i can get list of all android application installed on the device? 或者,我如何获得设备上安装的所有Android应用程序的列表? Im use titanium mobile. 我用钛金属手机。 Thanks! 谢谢!
You can get the all the installed applications like this.. 您可以获得所有已安装的应用程序。
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> appData = packageManager.queryIntentActivities(
mainIntent, 0);
for (ResolveInfo appInfo : appData) {
Application application = new Application();
application.setApplicationName(appInfo.loadLabel(packageManager)
.toString());
}
The code that was written here is indeed a Java code. 这里编写的代码确实是一个Java代码。 I don't think Titanium exposes a methods that access the information you are looking for. 我不认为Titanium公开了一种访问您正在寻找的信息的方法。
What you can do is write your own native Titanium Module in Java that uses that uses the code kalyanpvs wrote you and use it from within javascript. 您可以做的是用Java编写自己的原生Titanium模块,使用kalyanpvs编写的代码并在javascript中使用它。
Check this out http://docs.appcelerator.com/titanium/latest/#!/guide/Android_Module_Development_Guide to learn more about module development for Android in titanium. 请查看http://docs.appcelerator.com/titanium/latest/#!/guide/Android_Module_Development_Guide ,了解有关Android钛模块开发的更多信息。
I'm guessing at your requirements slightly but it is possible to link a url to your app. 我正在猜测你的要求,但可以将网址链接到你的应用程序。
When you try and load that url from any source (eg an sms, an email) it will open the app if you have it, or else it will just open the url in your browser. 当您尝试从任何来源(例如短信,电子邮件)加载该网址时,如果您拥有该网址,它将打开该应用,否则它只会在您的浏览器中打开该网址。
See here: Android Respond To URL in Intent 请参阅此处: Android在Intent中响应URL
Does that help at all? 这些帮助有用?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.