Rohit Suthar
Rohit Suthar

Reputation: 987

How to remove parenthesis around the phone number

I'm loading the data into a RecyclerView. I want that after click on "mobile number string" it should be open in phone app without parenthesis means I want to open it in phone like a simple "Indian phone number". In my code it is open like this (879) 321-2686.

    holder.tv_mobileno.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i=new Intent(Intent.ACTION_DIAL);
            i.setData(Uri.parse("tel:"+product.getMobileno()));
            ctx.startActivity(i);
        }
    });

This is the image of the RecyclerView:

enter image description here

This is the output of phone app

enter image description here

Upvotes: 3

Views: 1467

Answers (2)

Nikunj
Nikunj

Reputation: 4157

holder.tv_mobileno.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Intent i=new Intent(Intent.ACTION_DIAL);
        i.setData(Uri.parse("tel:" + "+91" + product.getMobileno())); // --> add +91
        ctx.startActivity(i);
      }
});

Upvotes: 1

Abhishek Pandey
Abhishek Pandey

Reputation: 127

Take a String "mobNo" which holds the mobile number and then delete the first and fourth character, then call your method.

 i.setData(Uri.parse("tel:"+mobNo);

Upvotes: 0

Related Questions