0

I'm trying to develop an app in Android Studio in order to open Whatsapp or any other app by pressing a button in my own app. I try it in a Pixel 2 emulator and it works perfectly, however when I try it in my physical phone or tablet it does not recognize the app as installed and it redirect me to the playstore, as I set in the code. I don't know why because I have the app installed and I', sending the correct package name. If anyone can help it would be great. Thank you!!!

btnOpen= (Button) findViewById(R.id.idOpen);
        btnOpen.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = getPackageManager().getLaunchIntentForPackage("com.spotify");
                if (intent!=null){
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);}
                else{
                    intent = new Intent(Intent.ACTION_VIEW);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.setData(Uri.parse("market://details?id=" + "com.spotify"));
                    startActivity(intent);
                }
            }
        });

0 Answers0