好吧,我正在使用Google Maps,但我不明白这里出了什么问题。
我记得它曾经工作过,但是现在当我开始时它给了我错误。
查看代码和logcat
在尝试更改代码原因之前,我没有做任何尝试。
EL XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragments.VisitaAlClienteF"
>
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="VISITA AL CLIENTE EN LA UBICACION QUE VES EN EL
MAPA" />
<Button
android:id="@+id/btnYaEstoyAqui"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ya llegue" />
<com.google.android.gms.maps.MapView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/MapaVisitaAlCliente"
android:transitionName="com.google.android.gms.maps.MapFragment"
/>
</LinearLayout>
</FrameLayout>
JAVA VISITAR AL CLIENTE:
package com.example.david.gestiondeasistencia.Activies;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.example.david.gestiondeasistencia.Fragments.VisitaAlClienteF;
import com.example.david.gestiondeasistencia.R;
public class VisitarAlCliente extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_visitar_al_cliente);
Fragment fragmentoVisitalAlCliente = new VisitaAlClienteF();
getSupportFragmentManager().beginTransaction()
.replace(R.id.MapaVisitaAlCliente,fragmentoVisitalAlCliente).commit();
}
}
来访者片段:
public class VisitaAlClienteF extends Fragment implements GoogleMap.OnMarkerClickListener, LocationListener, OnMapReadyCallback, View.OnClickListener, Response.ErrorListener, Response.Listener<JSONObject> {
//Registro_del_empleado
private int registro_del_empleado;
//Administracion de Location del emppleado
LocationManager locationManager;
//Carnet de identidad del cliente que solicito el empleado
private String CarnetIdentidadDelCliente;
//Ubicaciones Dadas por el marcador seleccionado por el empleado
private double Latitud_DelMarcador_Seleccionado_porElempleado;
private double Longitud_DelMarcador_Seleccionado_porElempleado;
//Boton de ya llegue
private Button btnYaLlegue;
//DAtos de la raiz del root
private View rootView;
//datos del mapa
private MapView mapView;
private GoogleMap googleMap;
private CameraPosition posicionCamara;
//Datos de la solicitud del webservices
private RequestQueue reqest;
private JsonObjectRequest jsonObjectRequest;
public VisitaAlClienteF() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
this.rootView = inflater.inflate(R.layout.fragment_visita_al_cliente, container, false);
this.btnYaLlegue = (Button) this.rootView.findViewById(R.id.btnYaEstoyAqui);
this.btnYaLlegue.setOnClickListener(this);
this.registro_del_empleado = getActivity().getIntent().getIntExtra("registro_empleado",0);
this.locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
return rootView;
}
@Override
public void onResume() {
super.onResume();
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
this.mapView = (MapView) this.rootView.findViewById(R.id.MapaVisitaAlCliente);
if (this.mapView != null) {
this.mapView.onCreate(null);
this.mapView.onResume();
this.mapView.getMapAsync(this);
}
AgregarAlosClientes();
super.onViewCreated(view, savedInstanceState);
}
private void AgregarAlosClientes() {
this.reqest = Volley.newRequestQueue(getContext());
String url = "http://"+ConexionWebServices.DIR_HOST+"/WebServicesGestionAsistencia/RecuperarUbicacionesYClientes.php";
url = url.replace(" ", "%20");
this.jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, this, this);
this.reqest.add(jsonObjectRequest);
}
@Override
public void onMapReady(GoogleMap googleMap) {
this.googleMap = googleMap;
ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 101);
if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
this.posicionCamara = CameraPosition.builder()
.bearing(0)
.zoom(11)
.tilt(30)
.target(new LatLng(-17.7821614420627, -63.17951920243884))
.build();
this.googleMap.setOnMarkerClickListener(this);
this.googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(this.posicionCamara));
}
@Override
public void onResponse(JSONObject response) {
JSONArray arrayDeJsons = response.optJSONArray("UbicacionesClientes");
JSONObject unObjetoJson;
for (int i = 0; i < arrayDeJsons.length(); i++) {
try {
unObjetoJson = arrayDeJsons.getJSONObject(i);
MarkerOptions nuevoMarcador = new MarkerOptions();
nuevoMarcador.title(unObjetoJson.getString("ci_cliente"));
nuevoMarcador.snippet("Cliente :" + unObjetoJson.optString("nombre") + " " + unObjetoJson.optString("apellido") + " Estado :" + unObjetoJson.optString("Estado"));
nuevoMarcador.position(new LatLng(unObjetoJson.optDouble("latitud"), unObjetoJson.optDouble("longitud")));
this.googleMap.addMarker(nuevoMarcador);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
@Override
public void onLocationChanged(Location location) {
Location LugarDelCliente = new Location("ClienteLugar");
LugarDelCliente.setLatitude(this.Latitud_DelMarcador_Seleccionado_porElempleado);
LugarDelCliente.setLongitude(this.Longitud_DelMarcador_Seleccionado_porElempleado);
float metrosEntreempleadoYCliente = location.distanceTo(LugarDelCliente);
Toast.makeText(getContext(),String.valueOf(metrosEntreempleadoYCliente),Toast.LENGTH_LONG).show();
if(metrosEntreempleadoYCliente <= 1000){
RequestQueue requestCambiarEStado_Empleado = Volley.newRequestQueue(getContext());
JsonObjectRequest jsonObjectRequestCambiarEstado_Empleado;
String url = "http://"+ConexionWebServices.DIR_HOST+"/WebServicesGestionAsistencia/ActualizarEstadoEmpleado.php?registro_empleado="+this.registro_del_empleado+"&estado="+ Empleado.SI;
url = url.replace(" ","%20");
jsonObjectRequestCambiarEstado_Empleado = new JsonObjectRequest(JsonObjectRequest.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getContext(),"Usted esta en el trabajo (ClIENTE) porfavor no olvidar enviar su informe ",Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(),"Usted esta en el trabajo (ClIENTE) porfavor no olvidar enviar su informe ",Toast.LENGTH_LONG).show();
}
});
requestCambiarEStado_Empleado.add(jsonObjectRequestCambiarEstado_Empleado);
}
this.locationManager.removeUpdates(this);
CambiarUbicacion(location);
}
private void CambiarUbicacion(Location location) {
Calendar horarioEnlaCualEnvioUbicacionElEmpleado = Calendar.getInstance();
RequestQueue requestQueueActualizarUbicacion = Volley.newRequestQueue(getContext());
String Fecha = String.valueOf(horarioEnlaCualEnvioUbicacionElEmpleado.get(Calendar.YEAR))+"-"+String.valueOf(horarioEnlaCualEnvioUbicacionElEmpleado.get(Calendar.MONTH))+"-"+String.valueOf(horarioEnlaCualEnvioUbicacionElEmpleado.get(Calendar.DAY_OF_MONTH));
String URL = "http://"+ConexionWebServices.DIR_HOST+"/WebServicesGestionAsistencia/ActUltiUbicacionempleado.php?fecha="+Fecha+"&hora="+horarioEnlaCualEnvioUbicacionElEmpleado.get(Calendar.HOUR_OF_DAY)+":"+horarioEnlaCualEnvioUbicacionElEmpleado.get(Calendar.MINUTE)+"&latitud="+location.getLatitude()+"&longitud="+location.getLongitude()+"®istro_empleado="+this.registro_del_empleado;
JsonObjectRequest jsonObjectRequestActUbicacionEmpleado = new JsonObjectRequest(JsonObjectRequest.Method.GET, URL, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getContext(),"Ultima ubicacion Actualizada",Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(),"Ultima ubicacion Actualizada",Toast.LENGTH_LONG).show();
}
});
requestQueueActualizarUbicacion.add(jsonObjectRequestActUbicacionEmpleado);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onProviderDisabled(String provider) {
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnYaEstoyAqui:
Toast.makeText(getContext(), "supuestamente Llego", Toast.LENGTH_LONG).show();
if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
this.locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 0, this);
break;
}
}
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(),"No hay clientes para visitar",Toast.LENGTH_LONG).show();
}
@Override
public boolean onMarkerClick(Marker marker) {
this.Latitud_DelMarcador_Seleccionado_porElempleado = marker.getPosition().latitude;
this.Longitud_DelMarcador_Seleccionado_porElempleado = marker.getPosition().longitude;
Toast.makeText(getContext(),this.Latitud_DelMarcador_Seleccionado_porElempleado+" "+this.Longitud_DelMarcador_Seleccionado_porElempleado,Toast.LENGTH_LONG).show();
Toast.makeText(getContext(), "Se le ha asignado el cliente: "+marker.getSnippet()+" , Porfavor visitalo",Toast.LENGTH_LONG).show();
this.CarnetIdentidadDelCliente = marker.getTitle();
ModificarElEstadoAsignaciondelCliente();
ModEmpleadoyAsigCIDelCliente(this.registro_del_empleado,this.CarnetIdentidadDelCliente);
return false;
}
private void ModEmpleadoyAsigCIDelCliente(int registro_del_empleado, String carnetIdentidadDelCliente) {
RequestQueue requestQueueActEmplAsigCiCliente = Volley.newRequestQueue(getContext());
JsonObjectRequest jsonObjectRequestActEmplAsigCiCliente ;
String url = "http://"+ConexionWebServices.DIR_HOST+"/WebServicesGestionAsistencia/ActuEmpleadoAgregarCICliente.php?registro_empleado="+registro_del_empleado+"&ci_cliente="+carnetIdentidadDelCliente;
url = url.replace(" ","%20");
jsonObjectRequestActEmplAsigCiCliente = new JsonObjectRequest(JsonObjectRequest.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getContext(),"Se ha actualizado su estado y se le ha asignado un cliente",Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(),"Se ha actualizado su estado y se le ha asignado un cliente",Toast.LENGTH_LONG).show();
}
});
requestQueueActEmplAsigCiCliente.add(jsonObjectRequestActEmplAsigCiCliente);
}
private void ModificarElEstadoAsignaciondelCliente() {
RequestQueue requestModificarEstadoAsignacion;
JsonObjectRequest jsonObjectRequestModificarEstado;
requestModificarEstadoAsignacion = Volley.newRequestQueue(getContext());
String url = "http://"+ConexionWebServices.DIR_HOST+"/WebServicesGestionAsistencia/ActualizarEstadoAsignacionClienteServicio.php?ci_cliente="+this.CarnetIdentidadDelCliente;
url.replace(" ","%20");
jsonObjectRequestModificarEstado = new JsonObjectRequest(JsonObjectRequest.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
Toast.makeText(getContext(),"El cliente fue seleccionado usted debe visitarlo lo mas antes posible en este dia",Toast.LENGTH_LONG).show();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getContext(),"El cliente fue seleccionado usted debe visitarlo lo mas antes posible en este dia",Toast.LENGTH_LONG).show();
}
});
requestModificarEstadoAsignacion.add(jsonObjectRequestModificarEstado);
}
}
LOGCAT:
06-14 12:28:52.579 18230-18230/? E/Zygote: v2
06-14 12:28:52.579 18230-18230/? E/SELinux:
[DEBUG] get_category: variable s
einfo: default sensitivity: NULL, cateogry: NULL
06-14 12:28:55.099 18230-18230/com.example.david.
gestiondeasistencia
E/EmojiFactory_jni: Failed to load libemoji.so:
dlopen failed: library
"libemoji.so" not found
06-14 12:32:24.509 18230-18230/com.example.david.gestiondeasistencia
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.david.gestiondeasistencia, PID: 18230
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.example.david.gestiondeasistencia/
com.example.david.gestiondeasistencia.Activies.VisitarAlCliente}:
android.view.InflateException: Binary XML file line #2:
Error inflating class project
at
android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2656)
at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:2721)
at android.app.ActivityThread.access$900(ActivityThread.java:168)
at android.app.ActivityThread$H.handleMessage
(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5753)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.
run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: android.view.InflateException: Binary XML file line #2:
Error
inflating class project
at android.view.LayoutInflater.
createViewFromTag(LayoutInflater.java:757)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.AppCompatDelegateImpl.
setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.
setContentView(AppCompatActivity.java:140)
at
com.example.david.gestiondeasistencia.Activies.
VisitarAlCliente.onCreate(Visi
tarAlCliente.java:16)
at android.app.Activity.performCreate(Activity.java:6112)
at
android.app.Instrumentation.callActivityOnCreate
(Instrumentation.java:1117)
at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2609)
at
android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:2721)
at android.app.ActivityThread.access$900(ActivityThread.java:168)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5753)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Caused by: java.lang.ClassNotFoundException: Didn't find class
"android.view.project" on path: DexPathList[[zip file
"/data/app/com.example.david.gestiondeasistencia-1/base.apk", zip
file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_dependencies_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_0_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-1
/split_lib_slice_1_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_2_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_3_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_4_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_5_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_6_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_7_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_8_apk.apk", zip file
"/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/vendor/lib,
/system/lib]]
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.view.LayoutInflater.createView(LayoutInflater.java:571)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:665)
at com.android.internal.policy.
impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:65)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.support.v7.app.
AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.
AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.example.david.gestiondeasistencia.
Activies.VisitarAlCliente.onCreate(Visi
tarAlCliente.java:16)
at android.app.Activity.performCreate(Activity.java:6112)
at android.app.Instrumentation.
callActivityOnCreate(Instrumentation.java:1117)
at
android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2609)
at
android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:2721)
at android.app.ActivityThread.access$900(ActivityThread.java:168)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5753)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.
run(ZygoteInit.java:1405)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1200)
Suppressed: java.io.IOException: Zip archive
'/data/app/com.example.david.gestiondeasistencia-
1/split_lib_slice_1_apk.apk'
doesn't contain classes.dex (error msg: Entry not found)
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:295)
at dalvik.system.DexFile.<init