Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何检查zoom.us和Slack应用程序是否安装在Android上?_Android - Fatal编程技术网

如何检查zoom.us和Slack应用程序是否安装在Android上?

如何检查zoom.us和Slack应用程序是否安装在Android上?,android,Android,我正在尝试在Android中创建一个应用程序,用户可以在其中安装zoom.us和Slack应用程序并运行它们,但我需要在安装前检查该应用程序是否已经安装。问题是我不知道包的名称,所以我可以对照它们进行检查,zoom.us和slack的包的名称是什么,我如何通过单击zoom和slack按钮来运行它们 public class MainActivity extends AppCompatActivity { ImageButton zoom, slack; Butt

我正在尝试在Android中创建一个应用程序,用户可以在其中安装zoom.us和Slack应用程序并运行它们,但我需要在安装前检查该应用程序是否已经安装。问题是我不知道包的名称,所以我可以对照它们进行检查,zoom.us和slack的包的名称是什么,我如何通过单击zoom和slack按钮来运行它们

public class MainActivity extends AppCompatActivity {

        ImageButton zoom, slack;
        Button installZoom, installSlack;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);

            // Install zoom
            installZoom = (Button) findViewById(R.id.inst_zoom);
            if (isZoomClientInstalled(getApplicationContext())) {
                installZoom.setEnabled(false);
            } else {
                installZoom.setEnabled(true);

                installZoom.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_VIEW);
                        intent.addCategory(Intent.CATEGORY_BROWSABLE);
                        intent.setData(Uri.parse("https://play.google.com/store/apps/details?id=us.zoom.videomeetings"));
                        startActivity(intent);
                    }
                });
            }
            // Run zoom
            zoom = (ImageButton) findViewById(R.id.app_zoom);
            zoom.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {               
                    Toast.makeText(getApplicationContext(), "About to run zoom", Toast.LENGTH_SHORT).show();
                }
            });

            // Install Slack
            installSlack = (Button) findViewById(R.id.inst_slack);
            if (isSlckClientInstalled(getApplicationContext())) {
                installSlack.setEnabled(false);
            } else {
                installSlack.setEnabled(true);

                installSlack.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent();
                        intent.setAction(Intent.ACTION_VIEW);
                        intent.addCategory(Intent.CATEGORY_BROWSABLE);
                        intent.setData(Uri.parse("https://slack.com/downloads/android"));
                        startActivity(intent);
                    }
                });
            }

            // Run Slack
            slack = (ImageButton) findViewById(R.id.app_slack);
            slack.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Toast.makeText(getApplicationContext(), "About to run Slack", Toast.LENGTH_SHORT).show();
                }
            });

        }// End of Create();

        // Determine whether the zoom for Android client is installed on this device.
        public boolean isZoomClientInstalled(Context myContext) {
            PackageManager myPackageMgr = myContext.getPackageManager();
            try {
                myPackageMgr.getPackageInfo("???.???.??", PackageManager.GET_ACTIVITIES);
            } catch (PackageManager.NameNotFoundException e) {
                return (false);
            }
            return (true);
        }

        // Determine whether the Slack for Android client is installed on this device.
        public boolean isSlackClientInstalled(Context myContext) {
            PackageManager myPackageMgr = myContext.getPackageManager();
            try {
                myPackageMgr.getPackageInfo("???.???.??", PackageManager.GET_ACTIVITIES);
            } catch (PackageManager.NameNotFoundException e) {
                return (false);
            }
            return (true);
        }

}// End of class

若要检查应用程序是否已安装,您需要知道要检查的应用程序的程序包名称。你可以从谷歌play商店找到应用程序的软件包名称,关注URL。URL中的Id是包名

例如,对于Zoom.us,它是:us.Zoom.videomeetings


由于这两个应用程序都已建立,它们更新软件包名称的可能性很小。

您可以通过查看Google Play链接找到应用程序包

https://play.google.com/store/apps/details?id=com.Slack

Slack是这里的包名。us.zoom.zoom视频会议。然后你就开始有目的地做。试试看。

如果您知道该应用程序的软件包名称,那么您可以检查该应用程序是否安装在设备上

包名称:

Zoom.Us:Us.Zoom.videomeetings 松弛:com.Slack


您知道注释中所述的代码。通过运行它,您将知道该应用程序是否安装在设备上。

我已经检查了上面的代码“您需要知道软件包名称”,这正是我要问的。为什么要投反对票?希望我能解释为什么会有反对票。您说过您知道检查设备上是否安装了应用程序的代码。您还提供了不需要的大量代码。你的问题只是问两个应用程序的包名。你可以写一个简短的问题。但即便如此,这个问题也毫无价值,因为几乎所有android程序员都知道如何在play Store中检查应用程序的软件包名称。谢谢你的解释,我想我们都在生活和学习。