By Captain . Andreas


2020-03-26 03:24:15 8 Comments

I have about 12 buttons that each button opens phone apps by it's name. Now i can open messages and phone call but for other ones i don't know what should i put. This is my code for phone call:

        phone.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent phonecall = new Intent(Intent.ACTION_VIEW);
            phonecall.setData(Uri.parse("tel:"));
            startActivity(phonecall);
        }
    });

"tel:" will open phone call, now i want to know what should i put in "tel:" for other apps, Here's my other buttons need to open: Camera, Contacts, Browser, File Manager, Settings, Gallery, Clock, Telegram application, Instagram application, Whatsapp application.

1 comments

@nimi0112 2020-03-26 04:25:47

This is a part of Implicit Intent.

If you want the Android system to handle the intent for a particular task, you can use this.

        Intent callIntent = new Intent(Intent.ACTION_DIAL);
        callIntent.setData(Uri.parse("tel:" + Constants.CALL_CENTER_NUMBER));
        startActivity(callIntent);

Example: You can fire an Intent.ACTION_DIAL or Intent.ACTION_CALL without specifying any particular package name to handle this and Android system will handle this intent.

If you want your intent to be handled by a particular application then you can specify the package name of the application.

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.whatsapp");
startActivity( launchIntent );

@Captain . Andreas 2020-03-26 04:35:31

I don't want to share any text or do any task i just want that when i click on whatsapp button whatsapp open or if i click on contacts or gallery button contacts or gallery app open. just open that's it

@nimi0112 2020-03-26 04:49:45

@Captain.Andreas check updated answer

@Abhinav Chauhan 2020-03-26 04:52:55

@Captain.Andreas instead of copy pasting the code learn learn about intents -> developer.android.com/guide/components/intents-filters and developer.android.com/training/basics/intents/sending

Related Questions

Sponsored Content

3 Answered Questions

[SOLVED] Getting an exception when app starts

  • 2011-05-22 18:43:12
  • Serentty
  • 3299 View
  • 8 Score
  • 3 Answer
  • Tags:   android

1 Answered Questions

[SOLVED] Gallery button opens camera and gallery

  • 2019-10-02 07:12:45
  • Ruben Meiring
  • 35 View
  • 0 Score
  • 1 Answer
  • Tags:   java android camera

3 Answered Questions

2 Answered Questions

custom text passed to ACTION_CALL activity

  • 2011-02-07 22:37:57
  • MarkF
  • 530 View
  • 1 Score
  • 2 Answer
  • Tags:   android

3 Answered Questions

[SOLVED] Android open image in gallery with slide through images

1 Answered Questions

[SOLVED] Error message -> shouldOverrideUrlLoading Webview Android

2 Answered Questions

[SOLVED] Phone call intent

  • 2013-02-12 14:46:19
  • crodie
  • 1795 View
  • 1 Score
  • 2 Answer
  • Tags:   android

Sponsored Content