Skip to main content
deleted 2286 characters in body
Source Link
yams
  • 952
  • 8
  • 28
  • 61

JustOk so you have an example I amchanged my answer I found out there is a way to find out if there is anything overriding your libs.... You are using the supportmapfragment as wellLocation Objects somewhere so here is the method that uses itadd this bit of code and the layoutdebug it when running one of those devices.xml file that corresponds with this.... The location object should be in your location listener.

/**
 * Shows the users current location on the map
 */
private void showCurrentLocationOnMap(){
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mf= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

    
    map = mf.getMap();
    
    //map = ((MapFragment) getFragmentManager().findFragmentByIdgetClass(R.id.map)).getMap();
    ll = new PointLocationListenergetProtectionDomain();

    boolean isGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    
    if getCodeSource(!isGPS){
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
        sendBroadcastgetLocation(intent);
    }
    
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, ll);
}

layout.xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/btn_draw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Get Directions"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_btn_find"
        android:layout_alignParentRight="true" />

    <EditText
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="@string/hnt_et_location"
        android:layout_toLeftOf="@id/btn_find" />

</RelativeLayout>



<fragment 
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

Are you using a LocationListener? You also need to add a LocationManager as shown in my code above.

Just so you have an example I am using the supportmapfragment as well so here is the method that uses it and the layout.xml file that corresponds with this.

/**
 * Shows the users current location on the map
 */
private void showCurrentLocationOnMap(){
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mf= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

    
    map = mf.getMap();
    
    //map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    ll = new PointLocationListener();

    boolean isGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    
    if (!isGPS){
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
        sendBroadcast(intent);
    }
    
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, ll);
}

layout.xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/btn_draw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Get Directions"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_btn_find"
        android:layout_alignParentRight="true" />

    <EditText
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="@string/hnt_et_location"
        android:layout_toLeftOf="@id/btn_find" />

</RelativeLayout>



<fragment 
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

Are you using a LocationListener? You also need to add a LocationManager as shown in my code above.

Ok so I changed my answer I found out there is a way to find out if there is anything overriding your libs.... You are using the Location Objects somewhere so add this bit of code and debug it when running one of those devices..... The location object should be in your location listener.

 location.getClass().getProtectionDomain().getCodeSource().getLocation() ;
added 67 characters in body
Source Link
yams
  • 952
  • 8
  • 28
  • 61

Just so you have an example I am using the supportmapfragment as well so here is the method that uses it and the layout.xml file that corresponds with this.

/**
 * Shows the users current location on the map
 */
private void showCurrentLocationOnMap(){
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mf= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

    
    map = mf.getMap();
    
    //map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    ll = new PointLocationListener();

    boolean isGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    
    if (!isGPS){
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
        sendBroadcast(intent);
    }
    
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, ll);
}

layout.xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/btn_draw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Get Directions"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_btn_find"
        android:layout_alignParentRight="true" />

    <EditText
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="@string/hnt_et_location"
        android:layout_toLeftOf="@id/btn_find" />

</RelativeLayout>



<fragment 
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

Are you using a LocationListener? You also need to add a LocationManager as shown in my code above.

Just so you have an example I am using the supportmapfragment as well so here is the method that uses it and the layout.xml file that corresponds with this.

/**
 * Shows the users current location on the map
 */
private void showCurrentLocationOnMap(){
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mf= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

    
    map = mf.getMap();
    
    //map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    ll = new PointLocationListener();

    boolean isGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    
    if (!isGPS){
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
        sendBroadcast(intent);
    }
    
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, ll);
}

layout.xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/btn_draw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Get Directions"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_btn_find"
        android:layout_alignParentRight="true" />

    <EditText
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="@string/hnt_et_location"
        android:layout_toLeftOf="@id/btn_find" />

</RelativeLayout>



<fragment 
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

Are you using a LocationListener?

Just so you have an example I am using the supportmapfragment as well so here is the method that uses it and the layout.xml file that corresponds with this.

/**
 * Shows the users current location on the map
 */
private void showCurrentLocationOnMap(){
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mf= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

    
    map = mf.getMap();
    
    //map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    ll = new PointLocationListener();

    boolean isGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    
    if (!isGPS){
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
        sendBroadcast(intent);
    }
    
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, ll);
}

layout.xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/btn_draw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Get Directions"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_btn_find"
        android:layout_alignParentRight="true" />

    <EditText
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="@string/hnt_et_location"
        android:layout_toLeftOf="@id/btn_find" />

</RelativeLayout>



<fragment 
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

Are you using a LocationListener? You also need to add a LocationManager as shown in my code above.

Source Link
yams
  • 952
  • 8
  • 28
  • 61

Just so you have an example I am using the supportmapfragment as well so here is the method that uses it and the layout.xml file that corresponds with this.

/**
 * Shows the users current location on the map
 */
private void showCurrentLocationOnMap(){
    lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mf= (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);

    
    map = mf.getMap();
    
    //map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    ll = new PointLocationListener();

    boolean isGPS = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
    
    if (!isGPS){
        Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
        intent.putExtra("enabled", true);
        sendBroadcast(intent);
    }
    
    lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 10000, 10, ll);
}

layout.xml file :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


    <Button
        android:id="@+id/btn_draw"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text=" Get Directions"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

    <Button
        android:id="@+id/btn_find"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/str_btn_find"
        android:layout_alignParentRight="true" />

    <EditText
        android:id="@+id/et_location"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:inputType="text"
        android:hint="@string/hnt_et_location"
        android:layout_toLeftOf="@id/btn_find" />

</RelativeLayout>



<fragment 
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>

Are you using a LocationListener?