Calling by Clicking the Number -- Android - android

I am trying to have it so that when the phone number is clicked, it makes a call. The phone number is displaying correctly, but nothing happens when I click it.
Why is this not working?
tvInfo.setText(Html.fromHtml("<a href='tel:15555555555'><b>(555) 555-5555</b></a>"));
Let me know if more information is needed. Thanks!

Try looking at Linkify. Set the phone number normally with setText, and then use Linkify.
tvInfo.setText("(555)555-5555");
Linkify.addLinks(tvInfo, Linkify.PHONE_NUMBERS);

Try this:
call.setText(Html.fromHtml("<u>" + "9999999999" + "</u>"));
call.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
number = call.getText().toString();
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + number));
startActivity(intent);
}
});

Related

Android Intent.ACTION_CALL: phone number with # char

I want to make a phone call to *142#
However, it dials *142 only, the # is ignored.
Here is my code
Button button = (Button) findViewById(R.id.balance);
myButton.setOnClickListener(new OnClickListener()
{
#Override
public void onClick(View view)
{
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + telephoneNumber));
startActivity(intent);
}
}
I set the telephoneNumber as *142# , but still it dials *142. What can I do to make sure it dials *142# ? with the # at the end ?
URL encode the number with URLEncoder.
# has special meaning in URI syntax and needs to be encoded as %23 to be treated literally as #.

Make phone call without getting phone number (click icon to call) in android?

I'm currently working on my 2nd program and stuck with phone calling, sending SMS, emailing, and showing location using Google Map. I'm using ImageButtons for all of these. User doesn't need to type any numbers or addresses (not using EditText to get user input). However, it doesn't work.
For example, when user click on Phone icon, it will make a call. However, I still need a user input (the actual message, not the destination number or email address) for sending SMS and email. I can do it if I use EditText. However, without using EditText, I cannot do it. How do I do this? I've added users permission in manifest file.
PhoneActivity .java
public class PhoneActivity extends Activity {
ImageButton btnphonecall;
String phoneNumber = "091111111";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_phone);
btnphonecall=(ImageButton)findViewById(R.id.imageButton1);
btnphonecall.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse("091111111"));
PhoneActivity.this.startActivity(i);
//I've tried startActivity(i) along but still doesn't work
}
});
}
Use this:
Uri number = Uri.parse("tel:"+091111111 );
Intent dial = new Intent(Intent.ACTION_CALL,
number);
dial.setPackage("com.android.phone");
PhoneActivity.this.startActivity(dial);
Try this:
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+phoneNumber));
startActivity(callIntent);

Make call on number click

I need a little help.
I have ,in my app, a textView which contains a phone number,and i want to make a call when i click that phone number.
I've already accomplished that:
sitePhone.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
String number = "tel:" + sitePhone.getText().toString().trim();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(number));
startActivity(callIntent);
}
});
Now the problem is that sometimes i have on my text view 2 or 3 phone numbers.Something like this: "07456443345 FAR: 0745456334".I take the phone number string from the database so it cannot be altered.
Any ides of how i can make a call on each number click? thanks in advance
i found a simple answer:
android:autoLink="phone" will to the trick.

Mail screen scrolls down to the bottom

I am invoking a mail intent in
ImageButton mail=(ImageButton)findViewById(R.id.mailgps);
mail.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
setContentView(R.layout.mail);
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
// TODO Auto-generated method stub
emailIntent.setType("text/plain");
String emailto[]={"myemail"};
String subject="GPS User Report";
String body="Welcome to Samarth Reporting service.Did you see an untracked Dustbin\n.A dustbin not at the right place??\nWant to suggest placement of a dustbin here.\nGo ahead we are all ears.\n.Your present location is\n Latitude: ";
body=body + "28.67890" + " and Longitudes: " + "79.78965";
body=body + "\n\nTell us more.";
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,emailto);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,body);
startActivity(emailIntent);
}
});
and getting the screen like this which ignores the EXTRA_EMAIL attribute as well as EXTRA_SUBJECT and then the body appears at the very bottom.How can I rectify this.??
Well it was a pretty stupid thing.
As earlier I was using another AVD I had the email client setup so it worked nicely.But on the new AVD I overlooked that.So "first" setup the email client then go for invoking intent.
Nonetheless the system should have a better way of handling such situations rather than showing a weird blank screen.

Android: Image button as a hyperlink, phone call, map directions?

I have a simple app that I'm putting together for my company. I have 4 buttons that I've created but can't seem to get them to link correctly. One button should open our mobile site, another button to call us, another button to map to us, and the final button linked to our "News" site. Any help would be greatly appreciated!
On your buttons, you should set OnClickListener, and to do some required actions you could see the example below:
To Open a Map with Certain Location
mapButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + your-location-geo-address));
startActivity(i);
}
});
To call certain number
callButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + telephone-number));
startActivity(i);
}
});
To open a website
linkButton.setOnClickListener(new OnClickListener(){
#Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(website-address));
startActivity(i);
}
});
Change "location-address", "telephone-number", and "website-address" with your own String value.
I hope this helps.
anmustangs answer is very good, but one thing I would like to add for the button you are making for a link to your site, where anmustangs wrote (website-address) instead of just typing in a site, it needs to put formatted correctly. For example, you can use "http://www.google.com" and yes you do need to use the quotation marks I put in there. I know I am years late to this thread but who knows who my post may help.

Categories

Resources