Android Intent.ACTION_CALL: phone number with # char - android

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 #.

Related

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);

Calling by Clicking the Number -- 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);
}
});

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.

Android about button to rate on market

I am little confused with this code am looking for somenthing similar i have a button that i want it to say rate and when click it takes you to the android market where the user can rate my application, please help
Button bRate = (Button) findViewById(R.id.button7);
bRate.setOnClickListener(new View.OnClickListener() {
//plus the code on the top here is my idea of the code
}
Elipse is saying something is wrong and I understand that iI need to put my market link but the button still doesn't work
I couldn't post it on the same page here is the link for the original question
Use application to rate it on market
You have just add your app package name...
https://play.google.com/store/apps/details?id=your packagename
And call using Intent.ACTION_VIEW
String str ="https://play.google.com/store/apps/details?id=com.zeustechnocrats.quickfoods";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
This was helpful for me to do the same thing using an image button. here the code I used.
final ImageButton mybutton = (ImageButton) findViewById(R.id.imageButton);
mybutton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
String str ="https://play.google.com/store/apps/details?id=ws.crandell.newspaperpuzzles";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
}
});
Example code you can use.
Change your_package_name to your.package.name. E.g. com.example.myapp
Java File:
public void ratebutton(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW)
.setData(Uri
.parse("https://play.google.com/store/apps/details?id=your_package_name"));
startActivity(intent);
}
Layout file:
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="ratebutton"
android:text="#string/rate"
android:layout_gravity="center_horizontal" />
strings.xml:
<string name="rate">Rate with 5 stars please</string>

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