I have a text view that contains an email and a phone number. My desired effect is that when the user taps the email, it opens the default emailing application and when the user taps the phone number, the application pulls it up in the dialer. With the code below:
XML:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/careers_guidance"
android:id="#+id/careers_guidance_text"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="5dp"
android:linksClickable="true"
android:textColorLink="#0000EE"
android:autoLink="all"/>
Java:
careersGuidance = view.findViewById(R.id.careers_guidance_text);
careersGuidance.setText(Html.fromHtml("<p>Help with choosing the right course and with thinking about where this might take you in the future.</p>" +
"<p>Tel: 01274 433043</p>Email: careers#bradfordcollege.ac.uk"));
When I run my application, only the email is clickable and works the way I want it to work, the phone number isn't clickable or highlighted.
However, I have noticed that if I remove the email address from the setText java code, and run the application. The phone number becomes blue and underlined as if it is clickable, but when I tap it, nothing happens.
How can I get this working?
Also, I have CALL_PHONE permissions granted in my manifest file, and also on my emulator device.
From the email (.ac.uk), I suppose that you are from UK. You just need to add your country phone number prefix to replace 0, which is +44. And you don't need to use Html.fromHtml.
careersGuidance.setText("Help with choosing the right course and with thinking about where this might take you in the future.\n\nTel: +441274433043\n\nEmail: careers#bradfordcollege.ac.uk");
In your xml, you just need this property
android:autoLink="all"
You have to add your country code into Tel no.
Like this :
careers_guidance_text.setText(Html.fromHtml("
<p>Help with choosing the right course and with thinking about where this might take you in the future.</p>"
+"<p>Tel: +441274 433043</p>
Email: <a href=\"mailto:careers#bradfordcollege.ac.uk\">
careers#bradfordcollege.ac.uk</a>"));
Also have to add CALL PHONE Permission in android manifest file.
uses-permission android:name="android.permission.CALL_PHONE".
Related
I develop an Android app. If I call
float.Parse("51.552058")
in Editor or App on my Mac Book (Language Setting English), it works fine. After publishing to Android (Language Setting German) the result of the Parse operation is not "51.552058" anymore but "5,155211E+09". I understand that this might be related to the device's language but I still don't really understand what is happening and why.
I also tried following with no success:
float.Parse("51.552058", System.Globalization.NumberStyles.Any)
float.Parse("51.552058", System.Globalization.NumberStyles.AllowDecimalPoint)
Did anyone stumble over this before?
float.Parse is culture dependent.
See e.g. from NumberFormatInfo
// '1,034,562.91' --> 1034562.91 (en-US)
// '1,034,562.91': FormatException (fr-FR)
// '1,034,562.91' --> 1034562.91 (Invariant)
Reason here is that in EU cultures the , is usually the decimal separator while the . is used as the group separator. So from the example above the correct format for fr-FR would be 1.034.562,91
You probably rather want to use CultureInfo.InvariantCulture like
float.Parse("51.552058", CultureInfo.InvariantCulture);
or directly NumberFormatInfo.InvariantInfo
float.Parse("51.552058", NumberFormatInfo.InvariantInfo);
which simply has defined
NumberDecimalSeparator .
NumberGroupSeparator ,
Is there a way to programatically set to read all views on talkback when certain action is fired (ex. button click) like it is when you tap with 3 fingers at once?
Thanks in advance.
Option 1 - if you just want to read some text: Use speech to text
please refer this answer
Text to speech is built into Android 1.6+. Here is a simple example of how to do it.
TextToSpeech tts = new TextToSpeech(this, this);
tts.setLanguage(Locale.US);
tts.speak("Text to say aloud", TextToSpeech.QUEUE_ADD, null);
More info: http://android-developers.blogspot.com/2009/09/introduction-to-text-to-speech-in.html
Option 2 - If you are particulate about using talkback
refer to this answer
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "pkgname/classname");
Settings.Secure.putString(getContentResolver(),
Settings.Secure.ACCESSIBILITY_ENABLED, "1");
Where the pkgname is your package name and the classname is the class name of your accessibility service.
If you need to enable several services or you don't want to destory the previous settings you might want to use : to seperate other services.
Also you might need to run as a system application and you might need the following permissions
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
this might not work on some versions of Android.
Also refer other answers to this question
PS. If it doesn't work, maybe you could find some luck in /data/data/com.android.providers.settings/databases/settings.db/secure, that's where Android stores secure settings.
Having an issue with my app when trying to run it on an Acer Iconia One 10 tablet that is loaded with Marshmallow 6.0. This app works perfectly on a Samsung Galaxy Tablet running Android 4.2.2.
The main view consists of a series of TextViews and EditTexts where the user can enter information. The fields need to be able to accept either text or numerals. I use the field android:inputType="textCapSentences" to accomplish this. It has always worked. However, with 6.0, I'm getting a weird behavior that I believe has to be some type of version issue. If I type in letters everything is fine. But when I try to enter a string like "Route 169", the numbers will not appear. If I type in "Route169" it puts the numbers up there. It seems that once I put in a , the EditText stops accepting input. I have tried every variation of android:input="someInputType" that could possibly work for me and nothing has fixed it. I also tried the android:digits="ABC....0123 " solution.
Here is my EditText definition:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/highwayNameEditText"
android:text="*****"
android:inputType="textCapSentences"
android:layout_below="#+id/highwayNameTextView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignRight="#+id/highwayNameTextView"
android:layout_alignEnd="#+id/highwayNameTextView" />
It is within a ScrollView using a RelativeLayout. I have also tried adding a key event listener to no avail.
Logcat shows the following messages when the keyboard character is successfully transfered to the EditText:
D/OpenGLRenderer: CacheTexture 4 upload: x, y, width height = 0, 261, 15, 19
When the entry fails, the following appears in logcat:
View Root Impl: **[ANR Warning]Input routeing takes more than 6000ms**
Input event delivered to android.view.View Root Impl$Early PostImeInputStage
Input event delivered to android.view.View RootImpl$Native PostImeInputStage
Input event delivered to android.view.View Root Impl$ View PostImeInputStage
Input event delivered to android.view.View Root Impl$ Synthetic InputStage
The sequence repeats.
Note: I have removed time, date, and location information from the output to make it more readable.
As you can see, the system saw a key press event. The character did not make it to the Edit Text string. There also appears to possibly be a timeout issue of some kind. Thank you for taking the time to read this.
I'm using Cordova 3.6.4 in Visual Studio 2013 Community Update 4 to build an apps with a "chat" functionality, the main reason that I use this technology is because I want to, hopefully, write once and can use it in all platforms such as Android phones, iPhones, all mobile phone browsers, all desktop browsers.
In order to let the users inputting the "message" to be sent, I create a [div] which is contenteditable="true" at the bottom left of the html, at the right hand side of this [div], I have two [image buttons], one is the [happy face] button, the other is the [send button]. (You know, just like Whatsapp, Line and WeChat!)
At any time the user can click the [happy face] button to select one of the many "face image" to insert into the cursor at the [div], then I'll add the html codes into the [div], e.g. div.innerHTML += '< img src="1.jpg">'
So, the innerHTML of this [div] can contain characters AND images, e.g.
12< img src="1.jpg" />34< img src="2.jpg" />
Of course, the actual display is:
12[1st Picture]34[2nd Picture]
If the cursor is at the end of this [div], and I clicked the [BACKSPACE], I expect the [2nd Picture] will be removed, if I clicked the [BACKSPACE] again, I expect the letter [4] will be removed from the [div], this is work at ALMOST every platform I mentioned including all mobile browsers in android and iphone/ipad, all desktop browsers. But it does not work when I build an Android app and run it in any Android phone.
Running it as a WebView in android phone, when I click the the [BACKSPACE], the letter [4] is removed instead of the [2nd Picture], when I click the [BACKSPACE] again, the letter[3] is removed. I can NEVER remove the 2 images no matter which IME I'm using.
To work around, I tried to add a keyup/keydown/keypress listener to the [BACKSPACE] but it never fires.
At last, to work around this [BUG], I need to add a third [X] image button and use JavaScript string.replace to remove the < img> tag when users click this [X] button, but it looks very stupid to the users!
It makes me crazy that ALL IMEs do not remove the image for me by pressing the [BACKSPACE], and if the key events are not fired, I cannot remove the images myself!
I tried ALMOST, I think, ALL the suggestions provided by stackoverflow but they don't work at all, either not applicable to CORDOVA, or with compilation error such as [command failed with exit code 8] in Visual Studio.
What should I do?
To make a phone call via HTML on an iPhone I create an <A/> tag with an href formatted as: <a href='tel:123-555-1212'>Dial Me</a>.
Is there an equivelant for HTML on Android?
CLARIFICATION - using the format href='tele:123-555-1212' does indeed work on on android. I was testing the app within a native Java wrapper on the device. It does not appear as if we can make a call from a web application hosted in a Native Wrapper.
Yes you can; it works on Android too:
tel: phone_number
Calls the entered
phone number. Valid telephone numbers
as defined in the IETF RFC 3966 are
accepted. Valid examples include the
following:
* tel:2125551212
* tel: (212) 555 1212
The Android browser uses the Phone app to handle the “tel” scheme, as defined by RFC 3966.
Clicking a link like:
2125551212
on Android will bring up the Phone app and pre-enter the digits for 2125551212 without autodialing.
Have a look to RFC3966
I have just written an app which can make a call from a web page - I don't know if this is any use to you, but I include anyway:
in your onCreate you'll need to use a webview and assign a WebViewClient, as below:
browser = (WebView) findViewById(R.id.webkit);
browser.setWebViewClient(new InternalWebViewClient());
then handle the click on a phone number like this:
private class InternalWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.indexOf("tel:") > -1) {
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
return true;
} else {
return false;
}
}
}
Let me know if you need more pointers.
Generally on Android, if you simply display the phone number, and the user taps on it, it will pull it up in the dialer. So, you could simply do
For more information, call us at <b>416-555-1234</b>
When the user taps on the bold part, since it's formatted like a phone number, the dialer will pop up, and show 4165551234 in the phone number field. The user then just has to hit the call button.
You might be able to do
For more information, call us at <a href='tel:416-555-1234'>416-555-1234</a>
to cover both devices, but I'm not sure how well this would work. I'll give it a try shortly and let you know.
EDIT:
I just gave this a try on my HTC Magic running a rooted Rogers 1.5 with SenseUI:
For more information, call us at <a href='tel:416-555-1234'>416-555-1234</a><br />
<br />
Call at <a href='tel:416-555-1234'>our number</a>
<br />
<br />
<a href='416-555-1234'>Blah</a>
<br />
<br />
For more info, call <b>416-555-1234</b>
The first one, surrounding with the link and printing the phone number, worked perfectly. Pulled up the dialer with the hyphens and all. The second, saying our number with the link, worked exactly the same. This means that using <a href='tel:xxx-xxx-xxxx'> should work across the board, but I wouldn't suggest taking my one test as conclusive.
Linking straight to the number did the expected: Tried to pull up the nonexistent file from the server.
The last one did as I mentioned above, and pulled up the dialer, but without the nice formatting hyphens.