无法导入LocationServices

时间:2015-02-12 13:34:56

标签: android geolocation location location-services

我正在尝试获取用户的当前位置。 我正在使用最新的谷歌播放服务作为图书馆项目。 我可以导入GoogleApiClient,但我无法导入 位置服务。 当我尝试导入时出现此错误:

The import com.google.android.gms.location.LocationServices cannot be resolved. 

库导入的屏幕截图。 enter image description here

尝试谷歌搜索,但我找不到解决方案。任何帮助将不胜感激。

Java代码:

package com.anabko.message.home;

import java.util.ArrayList;
import java.util.List;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.Location;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.Toast;


import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import     com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.LocationSource.OnLocationChangedListener;
import com.google.android.gms.maps.MapsInitializer;

public class TweetFragment extends Fragment implements  ConnectionCallbacks, OnConnectionFailedListener
{
private RecyclerView lvMessages;
private SwipeRefreshLayout swipeLayoutToday;
private ConnectionDetector connectionDetector;
private String mLatitude,mLongitude; 
private ArrayList<TweetInterface> tweets_list;
private Message_Adapter adapter;
private ImageView imgNewTweet; 
private SessionManager sessionManager;
GoogleApiClient.Builder mGoogleApiClient = null;

 @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) 
    {
        View view = inflater.inflate(R.layout.tweet_fragment, container, false);
        lvMessages = (RecyclerView)view.findViewById(R.id.lvmess_tweetfrag);  
        swipeLayoutToday = (SwipeRefreshLayout)view.findViewById(R.id.swipe_tweetfrag);  
        imgNewTweet= (ImageView)view.findViewById(R.id.imgnew_tweetfrag);   
        return view;         
    }


 @Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onViewCreated(view, savedInstanceState); 



    LinearLayoutManager x =  new LinearLayoutManager(getActivity());
    x.setOrientation(LinearLayoutManager.VERTICAL); 

    lvMessages.setLayoutManager(x);
    lvMessages.setItemAnimator(new DefaultItemAnimator());  

    tweets_list = new ArrayList<TweetInterface>();




}






    void buildGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
    }

    @Override
    public void onConnected(Bundle arg0) {
        // TODO Auto-generated method stub

    }


    @Override
    public void onConnectionSuspended(int arg0) {
        // TODO Auto-generated method stub

    }


    @Override
    public void onConnectionFailed(ConnectionResult arg0) {
        // TODO Auto-generated method stub

    }

}

0 个答案:

没有答案