English 中文(简体)
getting积地点
原标题:Error on getting gps location

I m developing an app that communicates with three remote services on my phone. For the communication i m trying to figure out which method is the best (intents or AIDL). I receive a stream via bluetooth in a rate of 4 streams/second with 15 bytes each and now i want to add my gps location in order to execute data logging. I need my gps location every second. Since the time in requestLocationUpdates is just a hint, i created a timer which asks for the last known location every second.

不幸的是,在我试图利用国际助老会进行沟通时,我会发现一个错误。 奇怪的是,如果一米故意将所收到数据传送到边远处,则所有工作都属于罚款。

谁能帮助我?

这里我的准则是:

    private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 0; //meters
    private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; //in Milliseconds
    private final MyLocationListener listener;
    private final LocationManager mLocationManager;
    private final List<String> providers;


    public Parser() {
         mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
         listener = new MyLocationListener();
         listener.onProviderEnabled(LocationManager.GPS_PROVIDER);
         mLocationManager.requestLocationUpdates(
                LocationManager.GPS_PROVIDER, 
                MINIMUM_TIME_BETWEEN_UPDATES, 
                MINIMUM_DISTANCE_CHANGE_FOR_UPDATES, 
                listener);
         providers = mLocationManager.getProviders(true);
         timer = new Timer();
    }

    public boolean parse(byte[] data) {
         gpsUpdater();
         ...
    }

    private void gpsUpdater() {
        timer.scheduleAtFixedRate(new TimerTask() {
            Location l = null;

            @Override
            public void run() {
                for(String s: providers) {
                    l = mLocationManager.getLastKnownLocation(s);
                    if(l != null) {
                        gps = true;
                        latitude = l.getLatitude();
                        longitude = l.getLongitude();
                    }
                }
            }
       }, 0, MINIMUM_TIME_BETWEEN_UPDATES);
   }


   public class MyLocationListener implements LocationListener {

    @Override
    public void onLocationChanged(Location arg0) {
        //TODO Auto-generated method stub
    }

    @Override
    public void onProviderDisabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onProviderEnabled(String provider) {
        // TODO Auto-generated method stub

    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        // TODO Auto-generated method stub

    }

}

这里的错误是:

04-06 15:06:43.015: E/AndroidRuntime(844): FATAL EXCEPTION: Timer-0 04-06 15:06:43.015: E/AndroidRuntime(844): java.lang.SecurityException: Binder invocation to an incorrect interface 04-06 15:06:43.015: E/AndroidRuntime(844): at android.os.Parcel.readException(Parcel.java:1322) 04-06 15:06:43.015: E/AndroidRuntime(844): at android.os.Parcel.readException(Parcel.java:1276) 04-06 15:06:43.015: E/AndroidRuntime(844): at android.location.ILocationManager$Stub$Proxy.getLastKnownLocation(ILocationManager.java:896) 04-06 15:06:43.015: E/AndroidRuntime(844): at android.location.LocationManager.getLastKnownLocation(LocationManager.java:1020) 04-06 15:06:43.015: E/AndroidRuntime(844): at pt.ua.droidshark.handler.Parser$1.run(Parser.java:446) 04-06 15:06:43.015: E/AndroidRuntime(844): at java.util.Timer$TimerImpl.run(Timer.java:284)

地点主管使用某种辅助器向我提供地点和电话,如果所有通信都是利用国际助老会进行,电话能否处理这种数量的信息? 我无法理解,在我使用意向时,它为什么会进行罚款,在使用国际助老会时总是会发现这一错误。

PS:由于有人提议,原因可能是工作班或活动班级的工时人数不足,我设立了一执行守则和一概情况相同的服务。 如果所有通信都使用意向进行,并在使用《国际公路货运公约》时发现错误,将予以罚款。

问题回答

我认为,你在一个并非活动或服务的类别中重新执行一项回收任务(timer.slateuleAtFixedRate()。 这可能是原因

1) Either you implement the listeners in an activity that stays alive so the location is updated according to the parameters set in requestLocationUpdates(), but this leaves the gps on and eats the battery

(2) 您在您的活动中设置了一名时间,并用背信弃义的方式从您的活动中抽出位置(见这一例子:)。 什么是使用户目前安乐团所在地最简单和最有力的途径?

3) 您可以执行一项服务,而共同系统所做的这种补充将给您带来工作:

• 确保你在文档中添加正确的许可。

Does it include this tag?

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签