了解是否安装了应用程序

编程入门 行业动态 更新时间:2024-10-25 16:17:08
本文介绍了了解是否安装了应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我认为这个问题说得很清楚:最好的方法是找出用户是否在手机上安装了Facebook或Whatsapp?我必须去包裹或者最好的方法是什么?

I think the question says it all: What is the best way to find out if the user has installed Facebook or Whatsapp on his phone? Do I have to go over the package or what is the best way for this?

推荐答案

这个问题回答了此处。您可以使用以下代码来检查程序包名称

This was question was answered here. You can using the following piece of code to check for the package name

com.facebook.android OR com.facebook.katana

com.facebook.android OR com.facebook.katana

代码:

public class Example extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Put the package name here... boolean installed = appInstalledOrNot("com.facebook.android"); if(installed) { //This intent will help you to launch if the package is already installed Intent LaunchIntent = getPackageManager() .getLaunchIntentForPackage("com.facebook.android"); startActivity(LaunchIntent); System.out.println("App already installed om your phone"); } else { System.out.println("App is not installed om your phone"); } } private boolean appInstalledOrNot(String uri) { PackageManager pm = getPackageManager(); boolean app_installed = false; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); app_installed = true; } catch (PackageManager.NameNotFoundException e) { app_installed = false; } return app_installed ; } }

更多推荐

了解是否安装了应用程序

本文发布于:2023-10-28 08:39:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1536121.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   安装了

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!