Kalpesh Choudhary
Kalpesh Choudhary

Reputation: 11

On button click open an app that isinstalled on your device in android studio

I am making an app in android studio. in that app I want that when i click on a button a chooser (open with) should open in that users can directly go from my to that app in my case i want to add phone pay and google pay in that chooser plz help

Upvotes: 1

Views: 294

Answers (1)

Deep Parsania
Deep Parsania

Reputation: 251

button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    
    
    Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
    
            likeIng.setPackage("com.instagram.android");
    
            try {
                startActivity(likeIng);
            } catch (ActivityNotFoundException e) {
                Toast.makeText(this, "App not installed", Toast.LENGTH_SHORT).show();
            }
                }
            }); 

Set you like to open app package here

likeIng.setPackage("com.instagram.android");

Upvotes: 1

Related Questions