GPS emulation

by olivier » Wed, 29 Apr 2009 01:07:49 GMT


Sponsored Links
 Hi all,

I am currently trying to simulate GPS fixs with android emulator, but
I encountered some problems. I can run the app, clic on the send
button in the emulator control, but, only the first click provides a
position. I am running an ubuntu jaunty, eclipse and SDK 1.5, on a
french system with the locale EN_US
Here is my code :

private class MyLocationListener implements LocationListener
            {
                @Override
                public void onLocationChanged(Location loc) {
                    if (loc != null) {
                        String s = "";
                        s += loc.getLatitude();
                        s += "   ";
                        s += loc.getLongitude();
                        Toast.makeText(getBaseContext(),
                            "Location changed : Lat: " + loc.getLatitude() +
                            " Lng: " + loc.getLongitude(),
                            Toast.LENGTH_SHORT).show();
                        Log.i("GPS", s);
                    }
                    else {
                        Log.i("Gps","loc_null");
                    }
                }

                @Override
                public void onProviderDisabled(String provider) {
                    // TODO Auto-generated method stub
                        Log.i("Gps","onProviderDisabled");
                }

                @Override
                public void onProviderEnabled(String provider) {
                    // TODO Auto-generated method stub
                        Log.i("Gps","onProviderEnabled");
                }

                @Override
                public void onStatusChanged(String provider, int status,
                    Bundle extras) {
                    // TODO Auto-generated method stub
                        Log.i("Gps","onStatusChanged : " + provider);
                }
            }

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       //---use the LocationManager class to obtain GPS locations---
        lm = (LocationManager) getSystemService
(Context.LOCATION_SERVICE);

        locationListener = new MyLocationListener();

        lm.requestLocationUpdates(
            LocationManager.GPS_PROVIDER,
            0,
            0,
            locationListener);

    }

Can you tell me what I am doing wrong ?

Regards,

Olivier

--~--~---------~--~----~------------~-------~--~----~



GPS emulation

by ellipsoidmob...@googlemail.com » Wed, 29 Apr 2009 17:16:30 GMT


 Are you changing the location set in the emulator before each click,
or are you just sending the same location repeatedly?

I suspect (but don't know for sure) that even with distance & time set
to 0 in requestLocationUpdates, an update won't be generated if the
new location is identical to the old location.
--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


GPS emulation

by Andreas Frey » Wed, 29 Apr 2009 17:28:38 GMT


 Hi,

i had a similar problem using the geo fix command - only the first
transmission of a newlocation worked.
Look @ here:



GPS emulation

by Olivier Tournaire » Wed, 29 Apr 2009 18:03:15 GMT


 i,

Hi,


I saw this post, same day as mine ;-)

I "solved" the problem with a dirty hack:


@Override
public void onLocationChanged(Location loc) {
if (loc != null) {
String s = "";
s += loc.getLatitude();
s += " ";
s += loc.getLongitude();
Log.i("GPS", s);
}
else {
Log.i("Gps","loc_null");
}
* lm.removeUpdates(locationListener);
lm.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
xxx,
xxx
locationListener); *
}

Crappy isn't it ?

Regards,

Olivier



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. First Android App

Hey all,

I'm building my first Android app, and it's pretty confusing.  I'm
picking it up pretty well (or at least the minimal stuff I need to
know at this point), but I'm having one fairly significant issue.  I
haven't been able to figure out how to start a new activity.

I know to create an intent: Intent launchSuccess = new Intent()
and I know to call startActivity(Intent intentname)

However, I'm not sure what to send into Intent() or what I have to do
in AndroidManifest.xml to get it to work.

Here's what I have:

--------------------------------------------------------------------------------------------
AndrAIM.java
--------------------------------------------------------------------------------------------
public class AndrAIM extends Activity {
    /** Called when the activity is first created. */

        Intent launchSuccess = new Intent(AndrAIM.this, Success.class);

    // Create an anonymous class to act as a button click listener.
   private OnClickListener sign_in_listener = new OnClickListener()
    {
        public void onClick(View v)
        {
                getInfo();
        }
    };

        @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);

        Button sign_in = (Button)findViewById(R.id.sign_in);
        sign_in.setOnClickListener(sign_in_listener);

    }

    public void getInfo(){
        final EditText passwordField = (EditText)
findViewById(R.id.password);
        String password = passwordField.getText().toString();

        final EditText unameField = (EditText)
findViewById(R.id.username);
        String username = unameField.getText().toString();

        if (validateLogin(username, password))
                startActivity(launchSuccess);

        else {

               TextView tv = new TextView(this);
               tv.setText("login failed!" + "\n" + "username: " +
username + "\n" + " password: " + password);
               setContentView(tv);
        }


    }

    public boolean validateLogin(String uname, String pword){
        if(uname.equals("username1"))
                if(pword.equals("password1"))
                        return true;
        return false;
    }
}

--------------------------------------------------------------------------------------------
main.xml
--------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget135"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
<TableLayout
android:id="@+id/widget164"
android:layout_width="317px"
android:layout_height="135px"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:stretchColumns="1"
android:layout_x="0px"
android:layout_y="2px"
<TableRow
android:id="@+id/widget165"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
<TextView
android:id="@+id/widget168"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="AndrAIM"
</TextView>
</TableRow>
<TableRow
android:id="@+id/widget166"
android:layout_width="182px"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
<TextView
android:id="@+id/widget169"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Screen Name:"
</TextView>
<EditText
android:id="@+id/username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
</EditText>
</TableRow>
<TableRow
android:id="@+id/widget167"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
<TextView
android:id="@+id/widget170"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password:"
</TextView>
<EditText
android:id="@+id/password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
</EditText>
</TableRow>
</TableLayout>
<Button
android:id="@+id/sign_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign in"
android:layout_x="240px"
android:layout_y="142px"
</Button>
</AbsoluteLayout>

The following is Success's entry in AndroidManifest.xml
 <activity android:label="@string/app_name" android:name="Success">
<intent-filter>
<action android:name="com.straightforwardcode.action.Success.MAIN">
</action></intent-filter></activity>


Any help would be greatly appreciated.

Thanks!

I have Success.java (which is the activity that I want to load) and
Success.xml, which defines its layout.

Essentially, I need to know what to do to get Success.java to load
--~--~---------~--~----~------------~-------~--~----~

2. Invoke Media Scanner without GUI?

Is there any way to invoke the media scanner without using the gui?
--~--~---------~--~----~------------~-------~--~----~

3. hey!!neeedd help to get started!!

4. list adapter for complex dynamic layouts

5. is this still true?

6. Notepadv1 - cannot locate the NotesdbAdaptor class

7. app using jni unable to load native library