Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7863089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:22:08+00:00 2026-06-02T23:22:08+00:00

I am new to android.I am developing an application in that i have two

  • 0

I am new to android.I am developing an application in that i have two buttons in 1 screen.I have to perform to different actions based on the particular button clicked.I have to differentiate according to which button is clicked.

public void showSelectedNumber(int type, String number)
{


         --->Here i have to set two conditions:
    1.This for call
         try 
         {
    //     Intent callIntent = new Intent(Intent.ACTION_CALL);      //Call options
    //////     Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    //////     while (cursor.moveToNext()) {
    //////         String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
    //////     }
    //     callIntent.setData(Uri.parse("tel:"+number));    
    //     startActivity(callIntent);


    This is for SMS:

        startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse("sms:"                         //sms options
                + number)));
         }
         catch (ActivityNotFoundException e) 
         {
         Log.e("helloandroid dialing example", "Call failed", e);
         }
        Toast.makeText(this, type + ": " + number, Toast.LENGTH_LONG).show();      
    }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T23:22:10+00:00Added an answer on June 2, 2026 at 11:22 pm

    Implement onClickListener in your activity class. And then register it with both buttons..

    buttonCall.setOnClickListener(this);
    buttonSMS.setOnClickListener(this);
    

    Now, on onClick() method

    @Override
    public void onClick(View v)
    {
     switch (v.getId())
      {
       case R.id.buttonCall: // id of your call button
       // Call button click..
       break;
    
       case R.id.buttonSMS:  // id of your SMS button
       // SMS button click
       break; 
      }
    }
    

    Above code is just for understanding, Real code may be different..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing Android application where I use this code: Date d=new Date(new
Hi i am new to android i am developing alarm application for that i
Hi i am developing android application. I that i have creating the dynamic table
I am new to android field. i am developing restaurant menu application, i have
I'm new to android developing but right now I'm working on an application that
i am new bie in android, I am developing an application in Android, and
i am creating a new android application.i am using the table layout. I have
I have been developing Android application, and I have one question - ListView uses
I'm developing an Android Application that has three very similar Activities. I would like
I'm new to android programming and i have a question I'm developing an alarm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.