private static Intent createCallActivityIntent(Context context,URLSpan[] urlSpans){
  TelephonyManager tm=(TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
  if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE) {
    return null;
  }
  for (int span_i=0; span_i < urlSpans.length; span_i++) {
    URLSpan urlSpan=urlSpans[span_i];
    String urlString=urlSpan.getURL();
    if (urlString.startsWith(TEL_PREFIX)) {
      Intent callIntent=new Intent(Intent.ACTION_DIAL,Uri.parse(urlString));
      callIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
      return callIntent;
    }
  }
  return null;
}

private static Intent createCallActivityIntent ( Context context , URLSpan [ ] urlSpans ) { TelephonyManager tm = ( TelephonyManager ) context . getSystemService ( Context . TELEPHONY_SERVICE ) ; if ( tm . getPhoneType ( ) == TelephonyManager . PHONE_TYPE_NONE ) { return null ; } for ( int span_i = 0 ; span_i < urlSpans . length ; span_i ++ ) { URLSpan urlSpan = urlSpans [ span_i ] ; String urlString = urlSpan . getURL ( ) ; if ( urlString . startsWith ( TEL_PREFIX ) ) { Intent callIntent = new Intent ( Intent . ACTION_DIAL , Uri . parse ( urlString ) ) ; callIntent . addFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ; return callIntent ; } } return null ; }
create an intent to take the user to dialer , or any other app capable of making phone calls . use the first phone number available . if no phone number is found , or if the device is not capable of making phone calls ( i . e . a tablet ) , return null .
