Autolink property for TextView is not working in Android? - android

I am using below code for opening dial up when clicking on TextView. The problem is it is not working on samsung tablet 10 inch device. It is opening a dialogue box with options 'saving contact' and 'close' rather than opening dial up. I have tested using the same code on Lenovo 7 inch(using api level 19) and Motorolla droid turbo (using api level 22) it is working fine but samsung 10 inch tablet (using api level 21) it is showing dialogue with mentioned options.Am I missing something or this is api specific behavior? Below is the code.
<TextView
android:layout_marginLeft="10dp"
android:textColor="#color/white_color"
android:layout_marginTop="10dp"
android:id="#+id/tv_phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="phone"
android:textColorLink="#color/white_color"
android:layout_below="#+id/tv_address"
android:text="PH: (800) 579-4875 (310) 534-1505" />

I am posting the answer. It may be helpful for others. The problem was not in the code or in xml. The problem was with the tablet hardware. My device does not have calling feature that means I don't have sim card slot in my tablet that's why I was not getting dial up screen.

You can setup click event handler to start dial. It must work for different firmware.
textView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:" + "phone number here"));
startActivity(intent);
}
});

Try this
TextView phone = (TextView) layout.findViewById(R.id.idPhone);
phone.setAutoLinkMask(Linkify.PHONE_NUMBERS);

Related

Why is Nexus 7 2012 Android 4.2.2 (WIFI Only) not finding Media Route Button by Id?

The FIT Radio App uses a MediaRoute.Callback that is initialized in my CommandInterface class, that controls playback for the normal audio as well as the Chromecast audio. The NowPlayingActivity is initially set as the mMediaRouteButtonHandler inside of the MediaRoute.Callback, only if the MediaRouteButton exists.
The now_playing.xml is now in the default layout, with protective measures in the java source code. Our first measure of protection against null pointer exceptions (with the G2) was removing the the MediaRouteButton from the default layout. The second measure that was taken to stop the null pointer exceptions was to add the null check in the NowPlayingActivity.setVisibility(int visibility) code sample below for any other version that may not provide the Button (N7, etc.).
The MediaRouter callback is added in the NowPlayingActvity.onResume(), and removed in the NowPlayingActvity.onPause(). The following sample displays the visibility handling in the MediaRoute.Callback.onRouteAdded:
public void onRouteAdded(MediaRouter router, RouteInfo route) {
if(hasMediaRouteButtonHandler()) mMediaRouteButtonHandler.setVisibility(View.VISIBLE);
++mRouteCount;
}
I have access to a Google G2, a Note 3, a Samsung S III, HTC One M7, and a Nexus 7. After starting the MediaRoute.Callback, the MediaRoute Button shows on all devices [using NowPlayingActivity.setVisibility(int visibility)], except with the Nexus 7 and the Google G2.
public void setVisibility(int visibility) {
if(getMediaRouteButton() != null) getMediaRouteButton().setVisibility(visibility);
}
I am using the findViewById(int) method in the NowPlayingActvity and it returns null in the latter cases (Nexus 7 & G2), but works on the S III, HTC One, and Note 3.
public MediaRouteButton getMediaRouteButton() {
return (MediaRouteButton) findViewById(R.id.media_route_button);
}
I have looked on StackOverflow for similar questions, and there were no real answers for the issue:
With the first question that I found the user figured it out eventually, and posted that he had no clear solution.
android.support.v7.app.MediaRouteButton does not display
Another question was answered by the poster, and the solution came from using a real device instead of the emulator:
Why my MediaRouteButton not available to find any cast devices?
I have debugged this with all the above devices, with Dirk (My Contractee) over my shoulder! So this is a critical issue guys, and we really need your help!
Thanks in advance,
Christopher Miller, posting on behalf of Dirk # Fit Radio.

Android:autoLink not working fully on my 4.4 device

I'm new to Android programming, and I had this weird problem, I wanted to make phone numbers in a list clickable, where they send you the the dialer, now this worked on my Android phone, but it seems to only work on numbers of 10-chars, but when I tested it on a virtual device with 4.1.2, it worked well on all numbers in the list, I later tried a 4.4.2 virtual device, and I had the same problem there.
From what I could find on Google, I think the problem starts from Jelly Bean, so, is there a solution to this?
I used this in the TextView element in the layout XML fileL
android:autoLink="phone"
Was facing the same issue, for all the numbers longer than 10digits, solution is to just format them correctly and instead of 00 add a + sign infront of them, like: if number 00447172737475 , autolink wont work, but for +447172737475 it will work , hope it helps
In my case I wanted any numbers work as phone autolink, and for me worked only this:
private void setAutoLinkForPhoneWorkaround(TextView textView, final String phoneText) {
textView.setText(phoneText);
textView.setPaintFlags(phoneText.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
textView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel:" + phoneText));
startActivity(intent);
}
});
}

How to hide error message after right value selected from select box in jQuery.validationEngine along jquery mobile?

I am using jQuery validationEngine with jQuery mobile plugin in my mobile page, am validating the dropdown list if it has empty value once I set proper value the error message is not getting in hide samsung galaxy android phones but same is working fine in sony xperia and also in normal web browser(PC), can somebody help to fix this ..
specifications,
jQuery Validation Engine 2.2, jquery-1.8.1.min, jquery.mobile-1.1.1.min,
along with symfony 1.1
The above is working fine in Android 4.0 but not working in android
2.2 and 2.3
Thanks in advance,
Finally I got solution for the my problem...
I override the validationEngine method on those fields on change of the select box,
$('#day').change(function(){
if( $(this).val()!= '日'){
$("#day").validationEngine('hide');
}
else {
$("#day").validationEngine('showPrompt', '* 半角数字でご入力して下さい。', 'red',"topLeft",true);
}
$("#confirm").validationEngine('detach');
$("#confirm").validationEngine('attach',{promptPosition : "topLeft"});
});

Contact Custom Field doesn't show up in HTC Sense

i wrote a custom syncadapter, which also added a custom field to the rawcontacts. Exactly how it is done in the SampleSyncAdapter or in this example with the last.fm-App. And it is working fine on the emulator.
The xml-file, which declares my custom field:
<ContactsSource xmlns:android="http://schemas.android.com/apk/res/android">
<ContactsDataKind
android:mimeType="vnd.com.google.cursor.item/vnd.alien.mimetype"
android:icon="#drawable/icon"
android:summaryColumn="data2"
android:detailColumn="data3"
android:detailSocialSummary="true" />
</ContactsSource>
The code to add the custom field to the data-table of the contactscontract-provider:
mContentUri = Data.CONTENT_URI.buildUpon().appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER, "true").build();
Builder mID = ContentProviderOperation.newInsert(mContentUri)
.withValue(Data.RAW_CONTACT_ID, getRawContactId())
.withValue(Data.MIMETYPE, "vnd.com.google.cursor.item/vnd.alien.mimetype")
.withValue(Data.DATA1, mContactInformations.get("mID"))
.withValue(Data.DATA2, mContext.getString(R.string.profile_text))
.withValue(Data.DATA3, mContext.getString(R.string.profile_id)+" "+mContactInformations.get("mID"));
But when I run them on my HTC Desire with HTC Sense installed, I can't see this custom field anymore?!? Has anyone experienced the same problem?
Any hint to get my custom field visible is highly appreciated!
Cheers Ali3n
The default contact viewers do not show custom fields.
There are some 3rd party apps that do show custom fields, a free one (but ad supported) is here
Unfortunately I did not found a real solution for that. But two things reduce the problem:
This problem did only appear on my old HTC Desire. On my sisters HTC Sensation the custom-field shows up as expected (nice fail from HTC in the first try oO)
Even better is, that the intent that would be started via this custom-field also shows up in the QuickContactBadge, which is used by the native HTC Contacts-App even on my HTC Desires Sense. Therefore the user can invoke my activity via the QuickContactBadge on old Senses versions and in new versions he also has the ability to use the custom-field.

Android 3.0 Use Physical Keyboard Setting

Background:
I recently purchased a Motorola XOOM Tablet along with the Desktop Dock and Bluetooth Keyboard accessories.
The dock and keyboard work great, but when I take the tablet off the dock to move away from my desk, the keyboard still remains paired with the device and I have to manually change the settings to use the soft keyboard. The same goes for when I set it back on the dock, I need to manually switch it back. It's not a huge problem, but it would be nice not to have to think about it.
So I tried downloading an app from the market that simply toggled Bluetooth on and off when connected or disconnected from a power source, which worked well for a while, but the background service would die after period and become useless until I manually restarted that.
TO THE POINT: I'm trying to write a little app/service for my tablet that will recognize when it has been docked/undocked and switch the "Use Physical Keyboard" setting accordingly.
I have started with a BroadcastReciever to recognize the Dock State:
public class DockBroadcastReciever extends BroadcastReceiver {
private final String DOCK_STATE_LABEL = "android.intent.extra.DOCK_STATE";
#Override
public void onReceive(Context context, Intent intent) {
Bundle extras = intent.getExtras();
String message = (extras.getInt(DOCK_STATE_LABEL) == Intent.EXTRA_DOCK_STATE_UNDOCKED) ? "Undocked" : "Docked";
Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
toast.show();
}
}
But I'm having trouble figuring out the best way to update the setting after the event is fired. I've poked around some examples using InputMethodManager, but all the methods seem to need a specific EditText or some other input to bind to.
Furthermore, I can't seem to find a corresponding constant that represents that setting anywhere in the docs, but graphically, it is located here: http://i.stack.imgur.com/esFaw.png
Can anyone help me out with this?
I would like for there to be a solution for changing the setting, but I am open to other ideas as well.
I have an app that does something similar. It can toggle wifi and bluetooth based on power.
You'll need to register some of this stuff in the AndroidManifest.xml file.
http://code.google.com/p/futonic-wifioncall/source/browse/AndroidManifest.xml
Project Open Source Site: http://code.google.com/p/futonic-wifioncall/
This isn't the solution but hopefully will give guidance on what you're trying to accomplish.

Categories

Resources