Remove unused embedded libpng.
[navit-package] / navit / android / src / org / navitproject / navit / NavitVehicle.java
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.navitproject.navit;
17
18 import android.app.Activity;
19 import android.content.Context;
20 import android.graphics.*;
21 import android.os.Bundle;
22 import android.os.Debug;
23 import android.view.*;
24 import android.util.Log;
25 import android.location.*;
26
27 public class NavitVehicle {
28         private LocationManager locationManager;
29         private int vehicle_callbackid;
30         public native void VehicleCallback(int id, Location location);
31
32         NavitVehicle (Context context, int callbackid) {
33                 locationManager = (LocationManager)context.getSystemService(Context.LOCATION_SERVICE);
34
35                 Criteria criteria = new Criteria();
36                 criteria.setAccuracy(Criteria.ACCURACY_FINE);
37                 criteria.setAltitudeRequired(true);
38                 criteria.setBearingRequired(true);
39                 criteria.setCostAllowed(true);
40                 criteria.setPowerRequirement(Criteria.POWER_HIGH);
41
42                 
43                 Log.e("NavitVehicle", "Providers "+locationManager.getAllProviders());
44                 String provider = locationManager.getBestProvider(criteria, false);
45                 Log.e("NavitVehicle", "Provider "+provider);
46                 Location location = locationManager.getLastKnownLocation(provider);
47                 vehicle_callbackid=callbackid;
48                 locationManager.requestLocationUpdates(provider, 0, 0, locationListener);
49         }
50         private final LocationListener locationListener = new LocationListener() {
51                 public void onLocationChanged(Location location) {
52                         
53                         // Log.e("NavitVehicle", "LocationChanged Accuracy " + location.getAccuracy() + " Altitude " + location.getAltitude() + " Bearing " + location.getBearing() + " Speed " + location.getSpeed() + " Latitude " + location.getLatitude() + " Longitude " + location.getLongitude());
54                         VehicleCallback(vehicle_callbackid, location);  
55                 }
56                 public void onProviderDisabled(String provider){}
57                 public void onProviderEnabled(String provider) {}
58                 public void onStatusChanged(String provider, int status, Bundle extras) {}
59         };
60 }