Example usage for android.location Address getMaxAddressLineIndex

List of usage examples for android.location Address getMaxAddressLineIndex

Introduction

In this page you can find the example usage for android.location Address getMaxAddressLineIndex.

Prototype

public int getMaxAddressLineIndex() 

Source Link

Document

Returns the largest index currently in use to specify an address line.

Usage

From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getCurrentGPSLocationBroadcastReceiver = new BroadcastReceiver() {
        @Override//from   ww w  .ja  v a 2  s. com
        public void onReceive(Context context, Intent intent) {

            //  if(!test) {
            // textView.append("\n" +intent.getExtras().get("coordinates"));
            if (intent.getExtras().containsKey("longitude")) {
                double longitude = (double) intent.getExtras().get("longitude");
                double latitude = (double) intent.getExtras().get("latitude");
                googleMap.clear();
                setMapView(longitude, latitude);

                Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault());
                try {
                    List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1);
                    if (addressList != null && addressList.size() > 0) {
                        Address address = addressList.get(0);
                        StringBuilder sb = new StringBuilder();
                        for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
                            sb.append(address.getAddressLine(i)).append("\n");
                        }

                        sb.append(address.getLocality()).append("\n");
                        sb.append(address.getPostalCode()).append("\n");
                        sb.append(address.getCountryName());

                        result.setLatitude(latitude);
                        result.setLongitude(longitude);

                        result.setCountryName(address.getCountryName());
                        result.setLocality(address.getLocality());
                        result.setZipCode(address.getPostalCode());

                        result.setLocation(sb.toString());

                        if (address.getCountryCode().equals("TW")) {
                            result.setAddress(
                                    address.getAddressLine(0).substring(3, address.getAddressLine(0).length()));
                            result.setLocation(
                                    address.getAddressLine(0).substring(3, address.getAddressLine(0).length()));
                        } else {
                            result.setAddress(sb.toString());
                            result.setLocation(sb.toString());

                        }
                    }
                } catch (IOException e) {
                    Log.e("", "Unable connect to Geocoder", e);
                }
                //test = true;
            }
            // }
        }
    };

    sendDataRequest = new JsonPutsUtil(getActivity());
    sendDataRequest.setServerRequestOrderManagerCallBackFunction(
            new JsonPutsUtil.ServerRequestOrderManagerCallBackFunction() {

                @Override
                public void createNormalOrder(NormalOrder order) {

                    if (progressDialog_loading != null) {
                        progressDialog_loading.cancel();
                        progressDialog_loading = null;
                    }
                    Intent intent = new Intent(getActivity(), ClientTakeRideSearchActivity.class);

                    Bundle b = new Bundle();
                    b.putInt(Constants.ARG_POSITION, Integer.valueOf(order.getTicket_id()));
                    intent.putExtras(b);
                    startActivity(intent);
                    //finish();
                }

                @Override
                public void cancelNormalOrder(NormalOrder order) {
                    Intent intent = new Intent(getActivity(), MainActivity.class);
                    startActivity(intent);
                    //finish();
                }
            });
}

From source file:tw.com.geminihsu.app01.fragment.Fragment_Client_Service_test.java

private void getCurrentAddress(double longitude, double latitude) {
    Geocoder geocoder = new Geocoder(getActivity(), Locale.getDefault());
    try {//from   ww w  .  ja  va2  s .c o  m
        List<Address> addressList = geocoder.getFromLocation(latitude, longitude, 1);
        if (addressList != null && addressList.size() > 0) {
            Address address = addressList.get(0);
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
                sb.append(address.getAddressLine(i)).append("\n");
            }

            sb.append(address.getLocality()).append("\n");
            sb.append(address.getPostalCode()).append("\n");
            sb.append(address.getCountryName());

            result.setLatitude(latitude);
            result.setLongitude(longitude);

            result.setCountryName(address.getCountryName());
            result.setLocality(address.getLocality());
            result.setZipCode(address.getPostalCode());

            result.setLocation(sb.toString());

            if (address.getCountryCode().equals("TW")) {
                result.setAddress(address.getAddressLine(0).substring(3, address.getAddressLine(0).length()));
                result.setLocation(address.getAddressLine(0).substring(3, address.getAddressLine(0).length()));
            } else {
                result.setAddress(sb.toString());
                result.setLocation(sb.toString());

            }
            curAddress = result.getAddress();
        }
    } catch (IOException e) {
        Log.e("", "Unable connect to Geocoder", e);
    }
    //test = true;

}

From source file:com.tingbacke.wearmaps.MobileActivity.java

/**
 * Updates my location to currentLocation, moves the camera.
 *
 * @param location/*from  ww  w. j a  v  a2s .  com*/
 */
private void handleNewLocation(Location location) {
    Log.d(TAG, location.toString());

    double latitude = location.getLatitude();
    double longitude = location.getLongitude();
    LatLng latLng = new LatLng(latitude, longitude);

    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

    CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng).zoom(18).bearing(0).tilt(25)
            .build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

    TextView myLatitude = (TextView) findViewById(R.id.textView);
    TextView myLongitude = (TextView) findViewById(R.id.textView2);
    TextView myAddress = (TextView) findViewById(R.id.textView3);
    ImageView myImage = (ImageView) findViewById(R.id.imageView);

    myLatitude.setText("Latitude: " + String.valueOf(latitude));
    myLongitude.setText("Longitude: " + String.valueOf(longitude));

    // Instantiating currDistance to get distance to destination from my location
    currDistance = getDistance(latitude, longitude, destLat, destLong);

    Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);

    try {
        List<Address> addresses = geocoder.getFromLocation(latitude, longitude, 1);

        if (addresses != null) {
            Address returnedAddress = addresses.get(0);
            StringBuilder strReturnedAddress = new StringBuilder("");
            for (int i = 0; i < returnedAddress.getMaxAddressLineIndex(); i++) {
                strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\n");
            }

            // Hardcoded string which searches through strReturnedAddress for specifics
            // if statements decide which information will be displayed
            String fake = strReturnedAddress.toString();

            if (fake.contains("stra Varvsgatan")) {

                myAddress.setText("K3, Malm Hgskola" + "\n" + "Cykelparkering: 50m" + "\n" + "Dest: "
                        + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.kranen);

            } else if (fake.contains("Lilla Varvsgatan")) {

                myAddress.setText("Turning Torso" + "\n" + "Caf: 90m " + "\n" + "Dest: "
                        + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.turning);

            } else if (fake.contains("Vstra Varvsgatan")) {

                myAddress.setText("Kockum Fritid" + "\n" + "Bankomat: 47m" + "\n" + "Dest: "
                        + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.kockum);

            } else if (fake.contains("Stapelbddsgatan")) {

                myAddress.setText("Stapelbddsparken" + "\n" + "Toalett: 63m" + "\n" + "Dest: "
                        + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.stapel);

            } else if (fake.contains("Stora Varvsgatan")) {

                myAddress.setText("Media Evolution City" + "\n" + "Busshllplats: 94m" + "\n" + "Dest: "
                        + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.media);

            } else if (fake.contains("Masttorget")) {

                myAddress.setText("Ica Maxi" + "\n" + "Systembolaget: 87m" + "\n" + "Dest: "
                        + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.ica);

            } else if (fake.contains("Riggaregatan")) {

                myAddress.setText("Scaniabadet" + "\n" + "\n" + "Dest: " + Math.round(currDistance) + "m away");
                myImage.setImageResource(R.mipmap.scaniabadet);

            } else if (fake.contains("Dammfrivgen")) {
                //fakear Turning Torso p min adress fr tillfllet
                myAddress.setText("Turning Torso" + "\n" + "453m away");
                myImage.setImageResource(R.mipmap.turning);
            }

            //myAddress.setText(strReturnedAddress.toString()+ "Dest: " + Math.round(currDistance) + "m away");
            /*
                            // Added this Toast to display address ---> In order to find out where to call notification builder for wearable
                            Toast.makeText(MobileActivity.this, myAddress.getText().toString(),
                Toast.LENGTH_LONG).show();
            */
            //Here is where I call the notification builder for the wearable
            showNotification(1, "basic", getBasicNotification("myStack"));

        } else {
            myAddress.setText("No Address returned!");
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        myAddress.setText("Cannot get Address!");
    }
}

From source file:eu.trentorise.smartcampus.jp.PlanNewJourneyFragment.java

private void savePosition(Address address, String field) {
    EditText text = null;/*from   w  w  w .j  ava 2  s.  c  o m*/
    ImageButton imgBtn = null;

    String s = "";
    for (int i = 0; i <= address.getMaxAddressLineIndex(); i++) {
        s += address.getAddressLine(i) + " ";
    }
    s = s.trim();

    if (field.equals(FROM)) {
        fromPosition = new Position(address.getAddressLine(0), null, null,
                Double.toString(address.getLongitude()), Double.toString(address.getLatitude()));
        if (getView() != null) {
            text = (EditText) getView().findViewById(R.id.plannew_from_text);
            imgBtn = (ImageButton) getView().findViewById(R.id.plannew_from_star);
        }
    } else if (field.equals(TO)) {
        toPosition = new Position(address.getAddressLine(0), null, null,
                Double.toString(address.getLongitude()), Double.toString(address.getLatitude()));

        if (getView() != null) {
            text = (EditText) getView().findViewById(R.id.plannew_to_text);
            imgBtn = (ImageButton) getView().findViewById(R.id.plannew_to_star);
        }
    }

    if (text != null) {
        text.setFocusable(false);
        text.setFocusableInTouchMode(false);
        text.setText(s);
        text.setFocusable(true);
        text.setFocusableInTouchMode(true);
    }

    if (imgBtn != null) {
        for (Position p : userPrefsHolder.getFavorites()) {
            if (address.getAddressLine(0).equalsIgnoreCase(p.getName())
                    || (address.getLatitude() == Double.parseDouble(p.getLat())
                            && address.getLongitude() == Double.parseDouble(p.getLon()))) {
                imgBtn.setImageResource(R.drawable.ic_fav_star_active);
                imgBtn.setTag(true);
            }
        }
    }
}

From source file:org.ohmage.reminders.types.location.LocTrigMapsActivity.java

/**
 * Converts an address to a marker to show on the map
 *
 * @param adr/*from  www  . j  av  a2 s . c o  m*/
 * @return
 */
private MarkerOptions addressToMarker(Address adr) {
    StringBuilder addrText = new StringBuilder();

    int addrLines = adr.getMaxAddressLineIndex();
    for (int i = 0; i < Math.min(2, addrLines); i++) {
        addrText.append(adr.getAddressLine(i)).append("\n");
    }
    return new MarkerOptions().position(new LatLng(adr.getLatitude(), adr.getLongitude()))
            .title(addrText.toString());
}

From source file:edu.usf.cutr.opentripplanner.android.tasks.OTPGeocoding.java

private ArrayList<Address> searchPlaces(String name) {
    HashMap<String, String> params = new HashMap<String, String>();
    Places p;/*ww w  .jav a 2s . c  o m*/

    /*params.put(Itract.PARAM_NAME, name);
    if (selectedServer != null) {
       params.put(Itract.PARAM_LAT, Double.toString(selectedServer.getGeometricalCenterLatitude()));
       params.put(Itract.PARAM_LON, Double.toString(selectedServer.getGeometricalCenterLongitude()));
    }
    p = new Itract();*/

    if (placesService.equals(context.getResources().getString(R.string.geocoder_google_places))) {
        params.put(GooglePlaces.PARAM_NAME, name);
        if (selectedServer != null) {
            params.put(GooglePlaces.PARAM_LOCATION,
                    Double.toString(selectedServer.getGeometricalCenterLatitude()) + ","
                            + Double.toString(selectedServer.getGeometricalCenterLongitude()));
            params.put(GooglePlaces.PARAM_RADIUS, Double.toString(selectedServer.getRadius()));
        }
        p = new GooglePlaces(getKeyFromResource());

        Log.v(TAG, "Using Google Places!");
    } else {
        params.put(Nominatim.PARAM_NAME, name);
        if (selectedServer != null) {
            params.put(Nominatim.PARAM_LEFT, Double.toString(selectedServer.getLowerLeftLongitude()));
            params.put(Nominatim.PARAM_TOP, Double.toString(selectedServer.getLowerLeftLatitude()));
            params.put(Nominatim.PARAM_RIGHT, Double.toString(selectedServer.getUpperRightLongitude()));
            params.put(Nominatim.PARAM_BOTTOM, Double.toString(selectedServer.getUpperRightLatitude()));
        }

        p = new Nominatim();

        Log.v(TAG, "Using Nominatim!");
    }

    ArrayList<POI> pois = new ArrayList<POI>();
    pois.addAll(p.getPlaces(params));

    ArrayList<Address> addresses = new ArrayList<Address>();

    for (int i = 0; i < pois.size(); i++) {
        POI poi = pois.get(i);
        Log.v(TAG, poi.getName() + " " + poi.getLatitude() + "," + poi.getLongitude());
        Address addr = new Address(context.getResources().getConfiguration().locale);
        addr.setLatitude(poi.getLatitude());
        addr.setLongitude(poi.getLongitude());
        String addressLine;

        if (poi.getAddress() != null) {
            if (!poi.getAddress().contains(poi.getName())) {
                addressLine = (poi.getName() + ", " + poi.getAddress());
            } else {
                addressLine = poi.getAddress();
            }
        } else {
            addressLine = poi.getName();
        }
        addr.setAddressLine(addr.getMaxAddressLineIndex() + 1, addressLine);
        addresses.add(addr);
    }

    return addresses;
}

From source file:dynamite.zafroshops.app.MainActivity.java

public LocationBase getAddress(boolean force) {
    Geocoder geocoder = new Geocoder(this, Locale.ENGLISH);
    SharedPreferences preferences = getPreferences(0);
    SharedPreferences.Editor editor = preferences.edit();
    boolean locationToggle = preferences.getBoolean(StorageKeys.LOCATION_TOGGLE_KEY, locationToggleDefault);

    try {//from ww  w  .  j av  a  2  s.  c o m
        if (!force && LastLocation != null) {

            if (preferences.contains(StorageKeys.COUNTRY_KEY)
                    && !preferences.getString(StorageKeys.COUNTRY_KEY, "").equals("")) {
                LastLocation.CountryCode = preferences.getString(StorageKeys.COUNTRY_KEY, "");
                LastLocation.Town = preferences.getString(StorageKeys.TOWN_KEY, "");
                LastLocation.Street = preferences.getString(StorageKeys.STREET_KEY, "");
                LastLocation.StreetNumber = preferences.getString(StorageKeys.STREETNUMBER_KEY, "");
            }
        } else if (locationToggle && LastLocation != null) {
            List<Address> addresses = geocoder.getFromLocation(LastLocation.Latitude, LastLocation.Longitude,
                    1);

            if (addresses != null && addresses.size() > 0) {
                Address address = addresses.get(0);

                LastLocation.CountryCode = address.getCountryCode();
                LastLocation.Town = address.getLocality();

                if (address.getMaxAddressLineIndex() > 0) {
                    String line = address.getAddressLine(0);

                    if (line.compareTo(LastLocation.Town) < 0) {
                        LastLocation.Street = line.replaceAll("(\\D+) \\d+.*", "$1");
                        LastLocation.StreetNumber = line.replaceAll("\\D+ (\\d+.*)", "$1");
                    }
                }

                editor.putString(StorageKeys.COUNTRY_KEY, LastLocation.CountryCode);
                editor.putString(StorageKeys.TOWN_KEY, LastLocation.Town);
                editor.putString(StorageKeys.STREET_KEY, LastLocation.Street);
                editor.putString(StorageKeys.STREETNUMBER_KEY, LastLocation.StreetNumber);
                editor.commit();
            }
        } else {
            return null;
        }

        return LastLocation;
    } catch (IOException e) {
        return null;
    }
}

From source file:edu.usf.cutr.opentripplanner.android.fragments.MainFragment.java

private String getStringAddress(Address address, boolean multiline) {
    if (address.getMaxAddressLineIndex() >= 0) {

        String result = address.getAddressLine(0);

        if (multiline) {
            for (int i = 1; i <= address.getMaxAddressLineIndex(); i++) {
                if (i == 1) {
                    result += "\n";
                    if (address.getAddressLine(i) != null) {
                        result += address.getAddressLine(i);
                    }// ww w .j  a  v a2 s . c  o  m
                } else if (i == 2) {
                    result += "\n";
                    if (address.getAddressLine(i) != null) {
                        result += address.getAddressLine(i);
                    }
                } else {
                    if (address.getAddressLine(i) != null) {
                        result += ", " + address.getAddressLine(i);
                    }
                }
            }
        } else {
            for (int i = 1; i <= address.getMaxAddressLineIndex(); i++) {
                if (address.getAddressLine(i) != null) {
                    result += ", " + address.getAddressLine(i);
                }
            }
        }

        return result;
    } else {
        return null;
    }
}

From source file:me.ububble.speakall.fragment.ConversationGroupFragment.java

private void muestraPosicion(final Location location) {
    milocManager.removeUpdates(this);
    Geocoder geoCoder = new Geocoder(activity, Locale.getDefault());
    List<Address> addresses = null;
    StringBuilder sb = new StringBuilder();
    try {/* ww w .j a v a  2 s.c  om*/
        addresses = geoCoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
        if (addresses != null && addresses.size() > 0) {
            for (Address address : addresses) {
                for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
                    sb.append(address.getAddressLine(i)).append("\n");
                }
            }
        }
        Log.w("UBICACION", sb.toString());
        MsgGroups msgGroup = new MsgGroups();
        JSONObject locationSend = new JSONObject();
        locationSend.put("direccion", sb.toString());
        locationSend.put("latitud", location.getLatitude());
        locationSend.put("longitud", location.getLongitude());
        long fecha = Calendar.getInstance().getTimeInMillis();
        JSONArray targets = new JSONArray();
        JSONArray contactos = new JSONArray(grupo.targets);
        String contactosId = null;
        if (SpeakSocket.mSocket != null) {
            if (SpeakSocket.mSocket.connected()) {
                for (int i = 0; i < contactos.length(); i++) {
                    JSONObject contacto = contactos.getJSONObject(i);
                    JSONObject newContact = new JSONObject();
                    Contact contact = new Select().from(Contact.class)
                            .where("id_contact = ?", contacto.getString("name")).executeSingle();
                    if (contact != null) {
                        if (!contact.idContacto.equals(u.id)) {
                            if (translate)
                                newContact.put("lang", contact.lang);
                            else
                                newContact.put("lang", u.lang);
                            newContact.put("name", contact.idContacto);
                            newContact.put("screen_name", contact.screenName);
                            newContact.put("status", 1);
                            contactosId += contact.idContacto;
                            targets.put(targets.length(), newContact);
                        }
                    }
                }
            } else {
                for (int i = 0; i < contactos.length(); i++) {
                    JSONObject contacto = contactos.getJSONObject(i);
                    JSONObject newContact = new JSONObject();
                    Contact contact = new Select().from(Contact.class)
                            .where("id_contact = ?", contacto.getString("name")).executeSingle();
                    if (contact != null) {
                        if (!contact.idContacto.equals(u.id)) {
                            if (translate)
                                newContact.put("lang", contact.lang);
                            else
                                newContact.put("lang", u.lang);
                            newContact.put("name", contact.idContacto);
                            newContact.put("screen_name", contact.screenName);
                            newContact.put("status", -1);
                            contactosId += contact.idContacto;
                            targets.put(targets.length(), newContact);
                        }
                    }
                }
            }
        }
        msgGroup.grupoId = grupo.grupoId;
        msgGroup.mensajeId = u.id + grupo.grupoId + fecha
                + Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID);
        msgGroup.emisor = u.id;
        msgGroup.receptores = targets.toString();
        msgGroup.mensaje = locationSend.toString();
        msgGroup.emisorEmail = u.email;
        msgGroup.emisorLang = u.lang;
        msgGroup.translation = translate;
        msgGroup.emitedAt = fecha;
        msgGroup.tipo = Integer.parseInt(getString(R.string.MSG_TYPE_GROUP_LOCATION));
        if (tiempoMensaje) {
            msgGroup.delay = temporizadorSeek.getValue();
        } else {
            msgGroup.delay = 0;
        }
        msgGroup.save();
        messageText.setText("");
        showNewMessage(msgGroup);
        messageClock.setTextColor(getResources().getColor(R.color.speak_all_gray));
        messageClock.setText(Finder.STRING.ICN_TEMPORIZER.toString());
        tiempoMensaje = false;
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:me.ububble.speakall.fragment.ConversationChatFragment.java

private void muestraPosicion(final Location location) {
    milocManager.removeUpdates(this);
    Geocoder geoCoder = new Geocoder(activity, Locale.getDefault());
    List<Address> addresses = null;
    StringBuilder sb = new StringBuilder();
    try {//from   w  w w  . j a v  a2 s  .  c o m
        addresses = geoCoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
        if (addresses != null && addresses.size() > 0) {
            for (Address address : addresses) {
                for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
                    sb.append(address.getAddressLine(i)).append("\n");
                }
            }
        }
        Log.w("UBICACION", sb.toString());
        Message msjNew = new Message();
        JSONObject locationSend = new JSONObject();
        locationSend.put("direccion", sb.toString());
        locationSend.put("latitud", location.getLatitude());
        locationSend.put("longitud", location.getLongitude());
        Calendar fecha = Calendar.getInstance();
        String id = u.id + contact.idContacto + fecha.getTimeInMillis()
                + Settings.Secure.getString(activity.getContentResolver(), Settings.Secure.ANDROID_ID);
        msjNew.translation = true;
        msjNew.mensajeId = id;
        msjNew.emisor = u.id;
        msjNew.receptor = contact.idContacto;
        msjNew.mensaje = locationSend.toString();
        msjNew.emisorEmail = u.email;
        msjNew.receptorEmail = contact.email;
        msjNew.emisorLang = u.lang;
        msjNew.receptorLang = contact.lang;
        msjNew.emitedAt = fecha.getTimeInMillis();
        msjNew.tipo = Integer.parseInt(getString(R.string.MSG_TYPE_LOCATION));
        msjNew.delay = 0;
        if (SpeakSocket.mSocket != null)
            if (SpeakSocket.mSocket.connected()) {
                msjNew.status = 1;
            } else {
                msjNew.status = -1;
            }
        msjNew.save();
        Chats chat = new Select().from(Chats.class).where("idContacto = ?", msjNew.receptor).executeSingle();
        if (chat == null) {
            Contact contact = new Select().from(Contact.class).where("id_contact = ?", msjNew.receptor)
                    .executeSingle();
            Chats newChat = new Chats();
            newChat.mensajeId = msjNew.mensajeId;
            newChat.idContacto = msjNew.receptor;
            newChat.isLockedConversation = false;
            newChat.lastStatus = msjNew.status;
            newChat.email = msjNew.receptorEmail;
            if (contact != null) {
                newChat.photo = contact.photo;
                newChat.fullName = contact.fullName;
                newChat.lang = contact.lang;
                newChat.screenName = contact.screenName;
                newChat.photoload = true;
                newChat.phone = contact.phone;
            } else {
                newChat.photo = null;
                newChat.photoload = false;
                newChat.fullName = msjNew.receptorEmail;
                newChat.lang = msjNew.receptorLang;
                newChat.screenName = msjNew.receptorEmail;
                newChat.phone = null;
            }
            newChat.emitedAt = msjNew.emitedAt;
            newChat.notRead = 0;
            newChat.lastMessage = "send Location";
            newChat.show = true;
            newChat.save();
        } else {
            if (!chat.photoload) {
                Contact contact = new Select().from(Contact.class).where("id_contact = ?", msjNew.emisor)
                        .executeSingle();
                if (contact != null) {
                    chat.photo = contact.photo;
                    chat.photoload = true;
                } else {
                    chat.photo = null;
                    chat.photoload = false;
                }
            }
            chat.mensajeId = msjNew.mensajeId;
            chat.lastStatus = msjNew.status;
            chat.emitedAt = msjNew.emitedAt;
            chat.notRead = 0;
            chat.lastMessage = "send Location";
            chat.save();
        }
        showNewMessage(msjNew);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}