dimanche 1 novembre 2015

Get the latitude and longitude from sqlite to open waze

I created an app composed of listview and map. When the user selects from the listview, a map will automatically goes to the location. Also the profile of location will show. The profile composed of button which when the user click, it will direct to waze and get the latitude of longitude. I dont know what's wrong with my code because it cant get the latitude and longitude of the locations. I think my problem is in the string url i cant get the lattitude and longitude but i dont know the right code to get it.

        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

              LatLng latLngtofocus = new LatLng(Double.parseDouble(GetLocation.get(i).getlatitude()),  Double.parseDouble(GetLocation.get(i).getlatitude()));

                    map.animateCamera(CameraUpdateFactory.newLatLngZoom(latlngtofocus, 17.0f));
                }


    LocationListView = findViewById(R.id.locationlayout);
                    ViewGroup parent = (ViewGroup) LocationListView.getParent();
                    parent.removeView(LocationListView);
                    // inflate your profile view (or get the reference to it if it's already inflated)
                    LocationProfileView = getLayoutInflater().inflate(R.layout.profile_location, parent, false);
                    // add it to the parent
                    parent.addView(LocationProfileView);

btnwaze = (Button) findViewById(R.id.waze);
                btnwaze.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        try
                        {
                            String url = "waze://?q=(Double.parseDouble(GetLocation.get(i).getlatitude()), Double.parseDouble(GetLocation.get(i).getlongitude()))";
                            Intent intent = new Intent( Intent.ACTION_VIEW, Uri.parse( url ) );
                            startActivity( intent );
                        }
                        catch ( ActivityNotFoundException ex  )
                        {
                            Intent intent =
                                    new Intent( Intent.ACTION_VIEW, Uri.parse( "market://details?id=com.waze" ) );
                            startActivity(intent);
                        }
                    }
                });
  });

Aucun commentaire:

Enregistrer un commentaire