日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

【Android Developers Training】 104. 接受地

系統(tǒng) 2761 0

注:本文翻譯自Google官方的Android Developers Training文檔,譯者技術(shù)一般,由于喜愛安卓而產(chǎn)生了翻譯的念頭,純屬個人興趣愛好。

原文鏈接: http://developer.android.com/training/location/receive-location-updates.html


如果你的應(yīng)用有導(dǎo)航的功能,你可能會希望可以定期獲取用戶的地理位置。雖然你可以通過 LocationClient.getLastLocation() 做到這一點(diǎn),但是一個更加直接的方法是向定位服務(wù)申請定期更新。作為響應(yīng),定位服務(wù)會自動用最佳的地理位置信息(基于當(dāng)前激活的可以提供位置信息的傳感器,如WiFi或者GPS)更新到你的應(yīng)用。

要從定位服務(wù)定期獲取地理位置更新,你使用定位客戶端發(fā)送一個請求。根據(jù)請求的形式,定位服務(wù)或是激活一個回調(diào)函數(shù),并把一個 Location 對象傳遞給該函數(shù),或是發(fā)送一個 Intent ,在其數(shù)據(jù)部分包含了地理位置信息。有兩方面因素會影響精度和頻率,一個是你的應(yīng)用申請的定位權(quán)限,一個是你在請求中傳遞給定位服務(wù)的參數(shù)。


一). 指定應(yīng)用權(quán)限

使用位置服務(wù)的應(yīng)用必須請求定位權(quán)限。Android有兩個定位權(quán)限: ACCESS_COARSE_LOCATION (粗定位)和 ACCESS_FINE_LOCATION (精定位)。你所選擇的權(quán)限決定了定位的精度。如果你只請求粗定位,位置服務(wù)所范圍的地點(diǎn)信息大致會精確到一個城市街區(qū)。

如果請求 ACCESS_FINE_LOCATION ,它也暗含了 ACCESS_COARSE_LOCATION 的權(quán)限。

例如,要添加 ACCESS_COARSE_LOCATION ,將下面的代碼作為 <manifest> 元素的子元素:

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

二). 檢查Google Play服務(wù)

位置服務(wù)是Google Play服務(wù)APK的其中一部分。由于用戶設(shè)備的狀態(tài)時難以預(yù)料的,你應(yīng)該一直在你嘗試連接定位服務(wù)之前,檢查APK是否已經(jīng)安裝。要檢查APK是否安裝,可以調(diào)用 GooglePlayServicesUtil.isGooglePlayServicesAvailable() ,它會返回一個整形的結(jié)果碼,其含義可以參閱: ConnectionResult 。如果你遇到了一個錯誤,可以調(diào)用 GooglePlayServicesUtil.getErrorDialog() ,來獲取一個本地的對話框,引導(dǎo)用戶執(zhí)行正確地行為,之后將這一對話框顯示在一個 DialogFragment 上。這一對話框可能允許用戶解決當(dāng)前的問題,此時Google Play服務(wù)會發(fā)回一個結(jié)果到你的activity中。要處理這一結(jié)果,需要覆寫 onActivityResult() 方法。

Note:

要使你的應(yīng)用可以兼容1.6及以后版本的系統(tǒng),顯示 DialogFragment 的activity必須是 FragmentActivity 的子類,而非 Activity 。使用 FragmentActivity 還可以允許你調(diào)用 getSupportFragmentManager() 方法來顯示 DialogFragment

由于你一直需要在你的代碼多個地方檢查Google Play服務(wù),所以應(yīng)該定義一個方法將檢查行為進(jìn)行封裝,之后在每次連接嘗試之前進(jìn)行檢查。下面的代碼片段包含了檢查Google Play服務(wù)所需要的代碼:

      
        public
      
      
        class
      
       MainActivity 
      
        extends
      
      
         FragmentActivity {

    ...

    
      
      
        //
      
      
         Global constants
      
      
        /*
      
      
        

     * Define a request code to send to Google Play services

     * This code is returned in Activity.onActivityResult

     
      
      
        */
      
      
        private
      
      
        final
      
      
        static
      
      
        int
      
      
        

            CONNECTION_FAILURE_RESOLUTION_REQUEST 
      
      = 9000
      
        ;

    ...

    
      
      
        //
      
      
         Define a DialogFragment that displays the error dialog
      
      
        public
      
      
        static
      
      
        class
      
       ErrorDialogFragment 
      
        extends
      
      
         DialogFragment {

        
      
      
        //
      
      
         Global field to contain the error dialog
      
      
        private
      
      
         Dialog mDialog;

        
      
      
        //
      
      
         Default constructor. Sets the dialog field to null
      
      
        public
      
      
         ErrorDialogFragment() {

            
      
      
        super
      
      
        ();

            mDialog 
      
      = 
      
        null
      
      
        ;

        }

        
      
      
        //
      
      
         Set the dialog to display
      
      
        public
      
      
        void
      
      
         setDialog(Dialog dialog) {

            mDialog 
      
      =
      
         dialog;

        }

        
      
      
        //
      
      
         Return a Dialog to the DialogFragment.
      
      
                @Override

        
      
      
        public
      
      
         Dialog onCreateDialog(Bundle savedInstanceState) {

            
      
      
        return
      
      
         mDialog;

        }

    }

    ...

    
      
      
        /*
      
      
        

     * Handle results returned to the FragmentActivity

     * by Google Play services

     
      
      
        */
      
      
        

    @Override

    
      
      
        protected
      
      
        void
      
      
         onActivityResult(

            
      
      
        int
      
       requestCode, 
      
        int
      
      
         resultCode, Intent data) {

        
      
      
        //
      
      
         Decide what to do based on the original request code
      
      
        switch
      
      
         (requestCode) {

            ...

            
      
      
        case
      
      
         CONNECTION_FAILURE_RESOLUTION_REQUEST :

            
      
      
        /*
      
      
        

             * If the result code is Activity.RESULT_OK, try

             * to connect again

             
      
      
        */
      
      
        switch
      
      
         (resultCode) {

                    
      
      
        case
      
      
         Activity.RESULT_OK :

                    
      
      
        /*
      
      
        

                     * Try the request again

                     
      
      
        */
      
      
        

                    ...

                    
      
      
        break
      
      
        ;

                }

            ...

        }

        ...

    }

    ...

    
      
      
        private
      
      
        boolean
      
      
         servicesConnected() {

        
      
      
        //
      
      
         Check that Google Play services is available
      
      
        int
      
       resultCode =
      
        

                GooglePlayServicesUtil.

                        isGooglePlayServicesAvailable(
      
      
        this
      
      
        );

        
      
      
        //
      
      
         If Google Play services is available
      
      
        if
      
       (ConnectionResult.SUCCESS ==
      
         resultCode) {

            
      
      
        //
      
      
         In debug mode, log the status
      
      

            Log.d("Location Updates"
      
        ,

                    
      
      "Google Play services is available."
      
        );

            
      
      
        //
      
      
         Continue
      
      
        return
      
      
        true
      
      
        ;

        
      
      
        //
      
      
         Google Play services was not available for some reason
      
      

        } 
      
        else
      
      
         {

            
      
      
        //
      
      
         Get the error code
      
      
        int
      
       errorCode =
      
         connectionResult.getErrorCode();

            
      
      
        //
      
      
         Get the error dialog from Google Play services
      
      

            Dialog errorDialog =
      
         GooglePlayServicesUtil.getErrorDialog(

                    errorCode,

                    
      
      
        this
      
      
        ,

                    CONNECTION_FAILURE_RESOLUTION_REQUEST);

            
      
      
        //
      
      
         If Google Play services can provide an error dialog
      
      
        if
      
       (errorDialog != 
      
        null
      
      
        ) {

                
      
      
        //
      
      
         Create a new DialogFragment for the error dialog
      
      

                ErrorDialogFragment errorFragment =

                        
      
        new
      
      
         ErrorDialogFragment();

                
      
      
        //
      
      
         Set the dialog in the DialogFragment
      
      
                        errorFragment.setDialog(errorDialog);

                
      
      
        //
      
      
         Show the error dialog in the DialogFragment
      
      
                        errorFragment.show(

                        getSupportFragmentManager(),

                        
      
      "Location Updates"
      
        );

            }

        }

    }

    ...

}
      
    

在后續(xù)章節(jié)的代碼片段中,都會調(diào)用這一方法來驗(yàn)證是否可獲取Google Play服務(wù)。


三). 定義位置服務(wù)回調(diào)函數(shù)

在你創(chuàng)建定位客戶端之前,實(shí)現(xiàn)定位服務(wù)的接口,以和你的應(yīng)用進(jìn)行交互:

ConnectionCallbacks

指定當(dāng)定位連接上或者沒有連接上時,定位服務(wù)調(diào)用的方法。

OnConnectionFailedListener

指定當(dāng)嘗試連接到定位客戶端時,如果出現(xiàn)了錯誤,定位服務(wù)調(diào)用的方法。這一方法使用之前定義的 showErrorDialog 方法來顯示一個錯誤對話框,它嘗試使用Google Play服務(wù)來解決這一問題。

下面的樣例代碼展示了如何指定接口和定義相關(guān)的函數(shù):

      
        public
      
      
        class
      
       MainActivity 
      
        extends
      
       FragmentActivity 
      
        implements
      
      
        

        GooglePlayServicesClient.ConnectionCallbacks,

        GooglePlayServicesClient.OnConnectionFailedListener {

    ...

    
      
      
        /*
      
      
        

     * Called by Location Services when the request to connect the

     * client finishes successfully. At this point, you can

     * request the current location or start periodic updates

     
      
      
        */
      
      
        

    @Override

    
      
      
        public
      
      
        void
      
      
         onConnected(Bundle dataBundle) {

        
      
      
        //
      
      
         Display the connection status
      
      

        Toast.makeText(
      
        this
      
      , "Connected"
      
        , Toast.LENGTH_SHORT).show();

    }

    ...

    
      
      
        /*
      
      
        

     * Called by Location Services if the connection to the

     * location client drops because of an error.

     
      
      
        */
      
      
        

    @Override

    
      
      
        public
      
      
        void
      
      
         onDisconnected() {

        
      
      
        //
      
      
         Display the connection status
      
      

        Toast.makeText(
      
        this
      
      , "Disconnected. Please re-connect."
      
        ,

                Toast.LENGTH_SHORT).show();

    }

    ...

    
      
      
        /*
      
      
        

     * Called by Location Services if the attempt to

     * Location Services fails.

     
      
      
        */
      
      
        

    @Override

    
      
      
        public
      
      
        void
      
      
         onConnectionFailed(ConnectionResult connectionResult) {

        
      
      
        /*
      
      
        

         * Google Play services can resolve some errors it detects.

         * If the error has a resolution, try sending an Intent to

         * start a Google Play services activity that can resolve

         * error.

         
      
      
        */
      
      
        if
      
      
         (connectionResult.hasResolution()) {

            
      
      
        try
      
      
         {

                
      
      
        //
      
      
         Start an Activity that tries to resolve the error
      
      
                        connectionResult.startResolutionForResult(

                        
      
      
        this
      
      
        ,

                        CONNECTION_FAILURE_RESOLUTION_REQUEST);

                
      
      
        /*
      
      
        

                * Thrown if Google Play services canceled the original

                * PendingIntent

                
      
      
        */
      
      
        

            } 
      
      
        catch
      
      
         (IntentSender.SendIntentException e) {

                
      
      
        //
      
      
         Log the error
      
      
                        e.printStackTrace();

            }

        } 
      
      
        else
      
      
         {

            
      
      
        /*
      
      
        

             * If no resolution is available, display a dialog to the

             * user with the error.

             
      
      
        */
      
      
        

            showErrorDialog(connectionResult.getErrorCode());

        }

    }

    ...

}
      
    

定義地理位置更新回調(diào)函數(shù)

定位服務(wù)或是以一個 Intent 的形式,或者以一個參數(shù)的形式將為之更新傳遞給一個你定義的回調(diào)函數(shù)。這節(jié)課將會講解如何使用一個回調(diào)函數(shù)來獲取更新,課程中使用的代碼基本可以用于任何應(yīng)用場景。如果你想要以一個 Intent 的形式接收位置更新,可以閱讀: Recognizing the User's Current Activity 。它提供了類似的可以參考的模板。

位置服務(wù)所調(diào)用的將為之更新發(fā)送給你的應(yīng)用的回調(diào)函數(shù)是在 LocationListener 接口的 onLocationChanged() 方法中指定的。傳入的參數(shù)是一個 Location 對象,包含了地點(diǎn)的經(jīng)緯度。下面的代碼片段展示了如何指定接口和定義方法:

      
        public
      
      
        class
      
       MainActivity 
      
        extends
      
       FragmentActivity 
      
        implements
      
      
        

        GooglePlayServicesClient.ConnectionCallbacks,

        GooglePlayServicesClient.OnConnectionFailedListener,

        LocationListener {

    ...

    
      
      
        //
      
      
         Define the callback method that receives location updates
      
      
            @Override

    
      
      
        public
      
      
        void
      
      
         onLocationChanged(Location location) {

        
      
      
        //
      
      
         Report to the UI that the location was updated
      
      

        String msg = "Updated Location: " +
      
        

                Double.toString(location.getLatitude()) 
      
      + "," +
      
        

                Double.toString(location.getLongitude());

        Toast.makeText(
      
      
        this
      
      
        , msg, Toast.LENGTH_SHORT).show();

    }

    ...

}
      
    

現(xiàn)在你已經(jīng)有了回調(diào)函數(shù),你可以配置位置更新的請求了。首先第一步是指定控制更新的參數(shù)。


四). 指定更新參數(shù)

定位服務(wù)允許你控制更新之間的時間間隔以及你期望的位置精確度,通過設(shè)置 LocationRequest 對象中的值,再將這一對象作為你的請求的一部分發(fā)出以開始更新。

首先,設(shè)置下列間隔參數(shù):

更新間隔:

通過 LocationRequest.setInterval() 設(shè)置。這一方法以毫秒為單位設(shè)置你的應(yīng)用接收更新的事件間隔。如果沒有其它應(yīng)用從定位服務(wù)接收更新,那么你的應(yīng)用將會以這一頻率接收更新。

最快更新間隔:

通過 LocationRequest.setFastestInterval() 設(shè)置。這一方法設(shè)置的是你的應(yīng)用能處理更新的最快間隔時間,以毫秒為單位。你需要設(shè)置這個頻率是因?yàn)槠渌鼞?yīng)用也會影響位置更新非頻率。定位服務(wù)會以所有應(yīng)用通過 LocationRequest.setInterval() 設(shè)置的最快的間隔時間來發(fā)送更新。如果這一頻率比你的應(yīng)用能夠處理的頻率要快,那么你可能會遇到UI閃爍或數(shù)據(jù)溢出等問題。為了避免這一情況發(fā)生,應(yīng)該調(diào)用 LocationRequest.setFastestInterval() 這一方法設(shè)置更新頻率的最高限額。

調(diào)用 LocationRequest.setFastestInterval() 方法還可以節(jié)省電量。當(dāng)你通過 LocationRequest.setInterval() 請求了一個更新間隔后,又用 LocationRequest.setFastestInterval() 請求了一個最大速率后,你的應(yīng)用會以正常速率進(jìn)行更新。如果其它應(yīng)用使用了一個更快的更新速率,那么你的更新頻率也會加快。如果沒有其它應(yīng)用申請了更快的更新速率,那么你的應(yīng)用會以 LocationRequest.setInterval() 中所設(shè)置的速率進(jìn)行更新。

接下來,設(shè)置精度參數(shù)。在一個前臺應(yīng)用程序中,你需要以高頻率更新地理位置,所以使用 LocationRequest.PRIORITY_HIGH_ACCURACY 設(shè)置精度。

下面的代碼片段展示課如何設(shè)置更新間隔和精度:

      
        public
      
      
        class
      
       MainActivity 
      
        extends
      
       FragmentActivity 
      
        implements
      
      
        

        GooglePlayServicesClient.ConnectionCallbacks,

        GooglePlayServicesClient.OnConnectionFailedListener,

        LocationListener {

    ...

    
      
      
        //
      
      
         Global constants
      
      
            ...

    
      
      
        //
      
      
         Milliseconds per second
      
      
        private
      
      
        static
      
      
        final
      
      
        int
      
       MILLISECONDS_PER_SECOND = 1000
      
        ;

    
      
      
        //
      
      
         Update frequency in seconds
      
      
        public
      
      
        static
      
      
        final
      
      
        int
      
       UPDATE_INTERVAL_IN_SECONDS = 5
      
        ;

    
      
      
        //
      
      
         Update frequency in milliseconds
      
      
        private
      
      
        static
      
      
        final
      
      
        long
      
       UPDATE_INTERVAL =
      
        

            MILLISECONDS_PER_SECOND 
      
      *
      
         UPDATE_INTERVAL_IN_SECONDS;

    
      
      
        //
      
      
         The fastest update frequency, in seconds
      
      
        private
      
      
        static
      
      
        final
      
      
        int
      
       FASTEST_INTERVAL_IN_SECONDS = 1
      
        ;

    
      
      
        //
      
      
         A fast frequency ceiling in milliseconds
      
      
        private
      
      
        static
      
      
        final
      
      
        long
      
       FASTEST_INTERVAL =
      
        

            MILLISECONDS_PER_SECOND 
      
      *
      
         FASTEST_INTERVAL_IN_SECONDS;

    ...

    
      
      
        //
      
      
         Define an object that holds accuracy and frequency parameters
      
      
            LocationRequest mLocationRequest;

    ...

    @Override

    
      
      
        protected
      
      
        void
      
      
         onCreate(Bundle savedInstanceState) {

        
      
      
        super
      
      
        .onCreate(savedInstanceState);

        
      
      
        //
      
      
         Create the LocationRequest object
      
      

        mLocationRequest =
      
         LocationRequest.create();

        
      
      
        //
      
      
         Use high accuracy
      
      
                mLocationRequest.setPriority(

                LocationRequest.PRIORITY_HIGH_ACCURACY);

        
      
      
        //
      
      
         Set the update interval to 5 seconds
      
      
                mLocationRequest.setInterval(UPDATE_INTERVAL);

        
      
      
        //
      
      
         Set the fastest update interval to 1 second
      
      
                mLocationRequest.setFastestInterval(FASTEST_INTERVAL);

        ...

    }

    ...

}
      
    

Note:

如果你的應(yīng)用要訪問網(wǎng)絡(luò)或者在接收到更新后需要做其它長期的任務(wù),那么應(yīng)該調(diào)整更新頻率到一個比較慢的值。這可以避免你的應(yīng)用接收到太多它來不及處理的更新數(shù)據(jù)。一旦長期處理的任務(wù)結(jié)束了,可以再通過設(shè)置最快更新頻率到一個較快的值。


五). 開始位置更新

要發(fā)送位置更新請求,在 onCreate() 創(chuàng)建一個定位客戶端,之后連接它,并通過 requestLocationUpdates() 發(fā)起請求。因?yàn)槟愕目蛻舳吮仨氝B接以后你的應(yīng)用才能收到更新,所以你應(yīng)該在 onStart() 方法中連接到客戶端。這能保證當(dāng)你的應(yīng)用可見時,你都能獲取一個已連接的有效的客戶端。因?yàn)槟阈枰诎l(fā)出請求前先進(jìn)行連接,所以在 ConnectionCallbacks.onConnected() 發(fā)出更新請求。

另外要記住用戶可能會有各種各樣的原因希望關(guān)閉位置更新。你應(yīng)該為用戶提供一個這樣做的方法,并且你應(yīng)該保證當(dāng)更新關(guān)閉了之后,你不會在 onStart() 中啟動更新。為了記錄用戶的設(shè)置,在 onPause() 方法中保存應(yīng)用的 SharedPreferences ,并在 onResume() 方法中獲取它。

下面的代碼片段展示了如何在 onCreate() 方法中設(shè)置客戶端,以及如何在 onStart() 方法中連接并發(fā)出更新請求:

      
        public
      
      
        class
      
       MainActivity 
      
        extends
      
       FragmentActivity 
      
        implements
      
      
        

        GooglePlayServicesClient.ConnectionCallbacks,

        GooglePlayServicesClient.OnConnectionFailedListener,

        LocationListener {

    ...

    
      
      
        //
      
      
         Global variables
      
      
            ...

    LocationClient mLocationClient;

    
      
      
        boolean
      
      
         mUpdatesRequested;

    ...

    @Override

    
      
      
        protected
      
      
        void
      
      
         onCreate(Bundle savedInstanceState) {

        ...

        
      
      
        //
      
      
         Open the shared preferences
      
      

        mPrefs = getSharedPreferences("SharedPreferences"
      
        ,

                Context.MODE_PRIVATE);

        
      
      
        //
      
      
         Get a SharedPreferences editor
      
      

        mEditor =
      
         mPrefs.edit();

        
      
      
        /*
      
      
        

         * Create a new location client, using the enclosing class to

         * handle callbacks.

         
      
      
        */
      
      
        

        mLocationClient 
      
      = 
      
        new
      
       LocationClient(
      
        this
      
      , 
      
        this
      
      , 
      
        this
      
      
        );

        
      
      
        //
      
      
         Start with updates turned off
      
      

        mUpdatesRequested = 
      
        false
      
      
        ;

        ...

    }

    ...

    @Override

    
      
      
        protected
      
      
        void
      
      
         onPause() {

        
      
      
        //
      
      
         Save the current setting for updates
      
      

        mEditor.putBoolean("KEY_UPDATES_ON"
      
        , mUpdatesRequested);

        mEditor.commit();

        
      
      
        super
      
      
        .onPause();

    }

    ...

    @Override

    
      
      
        protected
      
      
        void
      
      
         onStart() {

        ...

        mLocationClient.connect();

    }

    ...

    @Override

    
      
      
        protected
      
      
        void
      
      
         onResume() {

        
      
      
        /*
      
      
        

         * Get any previous setting for location updates

         * Gets "false" if an error occurs

         
      
      
        */
      
      
        if
      
       (mPrefs.contains("KEY_UPDATES_ON"
      
        )) {

            mUpdatesRequested 
      
      =
      
        

                    mPrefs.getBoolean(
      
      "KEY_UPDATES_ON", 
      
        false
      
      
        );



        
      
      
        //
      
      
         Otherwise, turn off location updates
      
      

        } 
      
        else
      
      
         {

            mEditor.putBoolean(
      
      "KEY_UPDATES_ON", 
      
        false
      
      
        );

            mEditor.commit();

        }

    }

    ...

    
      
      
        /*
      
      
        

     * Called by Location Services when the request to connect the

     * client finishes successfully. At this point, you can

     * request the current location or start periodic updates

     
      
      
        */
      
      
        

    @Override

    
      
      
        public
      
      
        void
      
      
         onConnected(Bundle dataBundle) {

        
      
      
        //
      
      
         Display the connection status
      
      

        Toast.makeText(
      
        this
      
      , "Connected"
      
        , Toast.LENGTH_SHORT).show();

        
      
      
        //
      
      
         If already requested, start periodic updates
      
      
        if
      
      
         (mUpdatesRequested) {

            mLocationClient.requestLocationUpdates(mLocationRequest, 
      
      
        this
      
      
        );

        }

    }

    ...

}
      
    

更多關(guān)于保存配置信息的知識,可以查看: Saving Key-Value Sets


六). 停止位置更新

要停止位置更新,在 onPause() 方法中保存更新標(biāo)識的狀態(tài),并在 onStop() 方法中通過調(diào)用 removeLocationUpdates(LocationListener) 來停止更新,例如:

      
        public
      
      
        class
      
       MainActivity 
      
        extends
      
       FragmentActivity 
      
        implements
      
      
        

        GooglePlayServicesClient.ConnectionCallbacks,

        GooglePlayServicesClient.OnConnectionFailedListener,

        LocationListener {

    ...

    
      
      
        /*
      
      
        

     * Called when the Activity is no longer visible at all.

     * Stop updates and disconnect.

     
      
      
        */
      
      
        

    @Override

    
      
      
        protected
      
      
        void
      
      
         onStop() {

        
      
      
        //
      
      
         If the client is connected
      
      
        if
      
      
         (mLocationClient.isConnected()) {

            
      
      
        /*
      
      
        

             * Remove location updates for a listener.

             * The current Activity is the listener, so

             * the argument is "this".

             
      
      
        */
      
      
        

            removeLocationUpdates(
      
      
        this
      
      
        );

        }

        
      
      
        /*
      
      
        

         * After disconnect() is called, the client is

         * considered "dead".

         
      
      
        */
      
      
        

        mLocationClient.disconnect();

        
      
      
        super
      
      
        .onStop();

    }

    ...

}
      
    

現(xiàn)在你已經(jīng)有了請求并接收定期位置更新的基本應(yīng)用框架。你可以將這節(jié)課中所講的東西結(jié)合到導(dǎo)航,行為識別,反地址解析等等場景中。

下一節(jié)課中,我們將會講解如何使用當(dāng)前地點(diǎn)顯示現(xiàn)在的街道地址。

【Android Developers Training】 104. 接受地點(diǎn)更新


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 固原市| 汝南县| 敖汉旗| 尼木县| 元阳县| 固安县| 岳阳市| 上杭县| 高清| 景洪市| 中山市| 开阳县| 体育| 龙门县| 合江县| 南陵县| 海晏县| 双城市| 湟源县| 南开区| 沙洋县| 峨眉山市| 龙泉市| 仁化县| 灌南县| 若尔盖县| 赤水市| 龙山县| 天峨县| 石门县| 神农架林区| 濮阳市| 罗田县| 承德市| 永清县| 大邑县| 新余市| 平泉县| 吉水县| 达日县| 寿宁县|