0

これでタワーIDとgpsを使用してgpsの場所を取得しています.現在の場所を取得してトーストに表示できます.5分ごとに自動的に表示する必要があります. 私のコードは

public void onClick(View arg0) {        
                // create class object
                gps = new GPSTracker(AndroidGPSTrackingActivity.this);

                // check if GPS enabled     
                if(gps.canGetLocation()){

                    double latitude = gps.getLatitude();
                    double longitude = gps.getLongitude();

                    // \n is for new line
                    Toast.makeText(getApplicationContext(), "Your Location is - \nLat: " + latitude + "\nLong: " + longitude, Toast.LENGTH_LONG).show();    
                }else{
                    Toast.makeText(getApplicationContext(),"cant get location", 1000 ).show(); 
                    // GPS or Network is not enabled
                    // Ask user to enable GPS/network in settings
                    gps.showSettingsAlert();
                }

            }
4

2 に答える 2

0

LocationManager.requestLocationUpdates を見てください。ロケーションプロバイダーが更新されると、自動的に更新されます。その API で最大頻度を 5 分に設定できます。

于 2013-04-17T06:01:37.837 に答える
0
   thread1=new Thread(new Runnable() {

            public void run() {
                // TODO Auto-generated method stub
                while (true) {
                    try {
                        Thread.sleep(1000*60*5);
                        mHandler.post(new Runnable() {


                            public void run() {
                                // TODO Auto-generated method stub
                                // Write your code here to update the UI.
                       });
                    } catch (Exception e) {
                        // TODO: handle exception
                    }
                }
            }
        });
于 2013-04-17T06:13:29.443 に答える