Java 类com.google.android.gms.location.LocationClient 实例源码

项目:mytracks    文件:MyTracksLocationManager.java   
public MyTracksLocationManager(Context context, Looper looper, boolean enableLocaitonClient) {
  this.context = context;
  this.handler = new Handler(looper);

  if (enableLocaitonClient) {
    locationClient = new LocationClient(context, connectionCallbacks, onConnectionFailedListener);
    locationClient.connect();
  } else {
    locationClient = null;
  }

  locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
  contentResolver = context.getContentResolver();
  observer = new GoogleSettingsObserver(handler);

  isAllowed = GoogleLocationUtils.isAllowed(context);

  contentResolver.registerContentObserver(
      GoogleLocationUtils.USE_LOCATION_FOR_SERVICES_URI, false, observer);
}
项目:nc-traffic-cams-open    文件:MainActivity.java   
/**
 * @param savedInstanceState
 */
private void applicationStartup() {
    if(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS) {
        mClient = new LocationClient(this, this, this);
        mClient.connect();
    } else {
        EasyTracker.getInstance(this).send(MapBuilder
          .createEvent(Category.Other.name(), "GooglePlayServicesNotAvailable", "", null)
          .build());
    }
    mCities = mGetLatestCamerasTask.getCities();
    mCacheParams = new ImageCacheParams("/image-cache");
    setImageQuality();
    configureAnalytics();
    mImageWorker = new ImageFetcher(this, 400);
    mImageWorker.setImageCache(ImageCache.findOrCreateCache(this,
            mCacheParams));
    mImageWorker.setLoadingImage(R.drawable.placeholder_camera);
    mFragment.setIsProcessing(false);
    mDrawerAdapter = new DrawerListAdapter(this,
            Arrays.asList((getResources().getStringArray(R.array.drawer_list_groups))),
            mCities);
    mDrawerList.setAdapter(mDrawerAdapter);
    selectGroup(mDrawerList, getCurrentGroup(), true);
}
项目:trolley-tracker-agent    文件:BackgroundLocationService.java   
@Override
public void onCreate() {
    super.onCreate();
    btsThis = this;

    Intent intent = new Intent(this, BackgroundLocationService.class);
    mLocationPendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);

    mInProgress = false;

    servicesAvailable = servicesConnected();

    /*
     * Create a new locationInfo client, using the enclosing class to
     * handle callbacks.
     */
    mLocationClient = new LocationClient(this, this, this);
}
项目:AndroidDemoProjects    文件:GeofencingService.java   
@Override
protected void onHandleIntent( Intent intent ) {
    NotificationCompat.Builder builder = new NotificationCompat.Builder( this );
    builder.setSmallIcon( R.drawable.ic_launcher );
    builder.setDefaults( Notification.DEFAULT_ALL );
    builder.setOngoing( true );

    int transitionType = LocationClient.getGeofenceTransition( intent );
    if( transitionType == Geofence.GEOFENCE_TRANSITION_ENTER ) {
        builder.setContentTitle( "Geofence Transition" );
        builder.setContentText( "Entering Geofence" );
        mNotificationManager.notify( 1, builder.build() );
    }
    else if( transitionType == Geofence.GEOFENCE_TRANSITION_EXIT ) {
        builder.setContentTitle( "Geofence Transition" );
        builder.setContentText( "Exiting Geofence" );
        mNotificationManager.notify( 1, builder.build() );
    }
}
项目:AndroidDemoProjects    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    verifyPlayServices();

    mLocationClient = new LocationClient( this, this, this );
    mIntent = new Intent( this, GeofencingService.class );
    mPendingIntent = PendingIntent.getService( this, 0, mIntent, PendingIntent.FLAG_UPDATE_CURRENT );

    mToggleButton = (ToggleButton) findViewById( R.id.geofencing_button );
    mToggleButton.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged( CompoundButton compoundButton, boolean b ) {
            if( b ) {
                startGeofence();
            } else {
                stopGeofence();
            }
        }
    });
}
项目:MockLocation    文件:MainActivity.java   
public void setMockLocation(final LatLng location) throws InterruptedException {
    client = new LocationClient(this, new GooglePlayServicesClient.ConnectionCallbacks() {
        @Override
        public void onConnected(Bundle bundle) {
            client.setMockMode(true);

            Location newLocation = new Location("flp");
            newLocation.setLatitude(location.latitude);
            newLocation.setLongitude(location.longitude);
            newLocation.setAccuracy(3f);

            client.setMockLocation(newLocation);
        }

        @Override
        public void onDisconnected() {

        }
    }, new GoogleApiClient.OnConnectionFailedListener() {
        @Override
        public void onConnectionFailed(ConnectionResult connectionResult) {
            Toast.makeText(MainActivity.this, "Make sure that Mock Location is enabled in developer settings", Toast.LENGTH_SHORT).show();
        }
    });
    client.connect();
}
项目:sharemyposition    文件:ShareByTracking.java   
@Override
protected void onHandleIntent(final Intent intent)
{
    Log.d(LOG, "onHandleIntent");
    this.wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOG);
    synchronized (this.wl) {
        this.wl.setReferenceCounted(false);
        this.wl.acquire();
    }
    if (intent.hasExtra(LocationClient.KEY_LOCATION_CHANGED) && intent.hasExtra(UUID)) {
        final NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
        if (activeNetwork != null && activeNetwork.isConnectedOrConnecting()) {
            final Bundle extras = intent.getExtras();
            final Location location = (Location) (extras.get(LocationClient.KEY_LOCATION_CHANGED));
            share(location, extras.getString(UUID));
        }
    }

}
项目:android-demos    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Create Location Client
    mLocationClient = new LocationClient(this, this, this);
    // Set up Location Request
    mLocationRequest = LocationRequest.create();
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setInterval(UPDATE_INTERVAL);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
    // UI elements
    mTextView = (TextView)findViewById(R.id.textView1);
    Button mButton = (Button)findViewById(R.id.button1);
    mButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) { displayLocation(); }
    });
}
项目:LocationUpdates    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mLatLng = (TextView) findViewById(R.id.lat_lng);
    mAddress = (TextView) findViewById(R.id.address);
    mActivityIndicator = (ProgressBar) findViewById(R.id.address_progress);
    mConnectionState = (TextView) findViewById(R.id.text_connection_state);
    mConnectionStatus = (TextView) findViewById(R.id.text_connection_status);

    mLocationRequest = LocationRequest.create();
    mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);
    mUpdatesRequested = false;
    mPrefs = getSharedPreferences(LocationUtils.SHARED_PREFERENCES, Context.MODE_PRIVATE);
    mEditor = mPrefs.edit();
    mLocationClient = new LocationClient(this, this, this);
}
项目:trigger.io-background_geolocation    文件:BackgroundLocationService.java   
@Override
public void onCreate() {
    super.onCreate();

    mInProgress = false;
    // Create the LocationRequest object
    mLocationRequest = LocationRequest.create();
    // Use high accuracy
    mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
    // Set the update interval to 5 seconds
    mLocationRequest.setInterval(Constants.UPDATE_INTERVAL);
    // Set the fastest update interval to 1 second
    mLocationRequest.setFastestInterval(Constants.FASTEST_INTERVAL);

    servicesAvailable = servicesConnected();

    /*
     * Create a new location client, using the enclosing class to
     * handle callbacks.
     */
    mLocationClient = new LocationClient(this, this, this);
}
项目:AndroidWearable-Samples    文件:MainActivity.java   
/**
 * Start a request for geofence monitoring by calling LocationClient.connect().
 */
public void addGeofences() {
    // Start a request to add geofences.
    mRequestType = REQUEST_TYPE.ADD;
    // Test for Google Play services after setting the request type.
    if (!isGooglePlayServicesAvailable()) {
        Log.e(TAG, "Unable to add geofences - Google Play services unavailable.");
        return;
    }
    // Create a new location client object. Since this activity class implements
    // ConnectionCallbacks and OnConnectionFailedListener, it can be used as the listener for
    // both parameters.
    mLocationClient = new LocationClient(this, this, this);
    // If a request is not already underway.
    if (!mInProgress) {
        // Indicate that a request is underway.
        mInProgress = true;
        // Request a connection from the client to Location Services.
        mLocationClient.connect();
    // A request is already underway, so disconnect the client and retry the request.
    } else {
        mLocationClient.disconnect();
        mLocationClient.connect();
    }
}
项目:sohacks    文件:CampingFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_camping, container,
            false);
    mLocationClient = new LocationClient(getActivity(), this, this);

    // 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);
    mLocationClient.connect();
    return rootView;
}
项目:sohacks    文件:ParksFragment.java   
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container,
            false);
    mLocationClient = new LocationClient(getActivity(), this, this);

    // 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);
    mLocationClient.connect();
    setHasOptionsMenu(true);

    return rootView;
}
项目:Android_OSM_offlinemap    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    d("In OnCreate");

    // fill data from generic.xml
    Utils.fillGenericData(this);

    locationClient = new LocationClient(this, this, this);
    d("BeforeRESTORE");
    restorePreferences();
    d("AfterRESTORE");
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    init();

    d("BeforeCONFIGURE");
    configureUI(savedInstanceState != null);
    d("AfterCONFIGURE");
    if (savedInstanceState != null) {
        restoreState(savedInstanceState);
    }

}
项目:tag-augmented-reality-android    文件:LocationRetriever.java   
private LocationRetriever(Context context) {
    super();

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

    // Create the LocationRequest object
    this.mLocationRequest = LocationRequest.create();
    // Use high accuracy
    this.mLocationRequest.setPriority(
            LocationRequest.PRIORITY_HIGH_ACCURACY);
    // Set the update interval to 5 seconds
    this.mLocationRequest.setInterval(UPDATE_INTERVAL);
    // Set the fastest update interval to 1 second
    this.mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
    this.latitude=0.0;
    this.longitude=0.0;


}
项目:MapAlarmist    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.activity_main);

    PreferenceManager.setDefaultValues(this, R.xml.settings, false);

    locationClient = new LocationClient(this, this, this);
    gMap = ((SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();
    disableNonScrollGestures();

    geoAlarm = new GeoAlarm();
    geoAlarm.restorePreferences(this);
    checkAlarm();
    initializeUI();
    loadAd();

    Log.d(GeoAlarmUtils.APPTAG, "CREATE");
}
项目:MapAlarmist    文件:GeoAlarm.java   
public void setAlarm(Context context, LocationClient locationClient,
        OnAddGeofencesResultListener listener) {
    /*
     * PendingIntent transitionPendingIntent =
     * getTransitionPendingIntent(context); List<Geofence> geofences = new
     * ArrayList<Geofence>(); geofences.add(buildGeofence());
     * locationClient.addGeofences(geofences, transitionPendingIntent,
     * listener);
     */

    AlarmManager am = (AlarmManager) context
            .getSystemService(Context.ALARM_SERVICE);
    PendingIntent alarmWakeUpPendingIntent = getAlarmWakeUpPendingIntent(context);
    am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, 2 * 60 * 1000,
            2 * 60 * 1000, alarmWakeUpPendingIntent);
    alarmSetTime = SystemClock.elapsedRealtime();
}
项目:Geo-Fi    文件:MainActivity.java   
/**
* @TODO Add description.
* 
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Obtain a reference to Google Map
    mGoogleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    // Enable My Location Layer
    mGoogleMap.setMyLocationEnabled(true);
    // Create a new global location parameters object
    mLocationRequest = LocationRequest.create();
    // Set the update interval
    mLocationRequest.setInterval(LocationUtils.UPDATE_INTERVAL_IN_MILLISECONDS);
    // Use high accuracy
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    // Set the interval ceiling to one minute
    mLocationRequest.setFastestInterval(LocationUtils.FAST_INTERVAL_CEILING_IN_MILLISECONDS);
    // Note that location updates are off until the user turns them on
    mUpdatesRequested = true;
    // Create a new location client, using the enclosing class to handle callbacks.
    mLocationClient = new LocationClient(this, this, this);

    wifiManager = (WifiManager) getBaseContext()
                        .getSystemService(Context.WIFI_SERVICE);
}
项目:trafficsense    文件:LocationOnlyService.java   
/**
 * Instantiate various resources.
 */
@Override
public void onCreate() {
    super.onCreate();
    mContext = this;
    mContainer = TrafficsenseContainer.getInstance();
    mRoute = mContainer.getRoute();
    mLocationClient=new LocationClient(this, this, this);
    mEnteredWaypointAlertReceiver = new EnteredWaypointAlertReceiver();

    Intent i = new Intent();
    i.setAction(Constants.ACTION_NEXT_GEOFENCE_REACHED);
    mGeofencePendingIntent = PendingIntent.getBroadcast(mContext, 1, i, 
            PendingIntent.FLAG_UPDATE_CURRENT);

    errorOnStart = false;
}
项目:androidmooc-clase4    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button btnDelete = (Button)findViewById(R.id.btnDelete);
    btnDelete.setOnClickListener(this);

       locationClient = new LocationClient(this, this, this);
       locationRequest = LocationRequest.create();

       locationRequest.setInterval(UPDATE_INTERVAL_IN_MILLISECONDS);
       locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
       locationRequest.setFastestInterval(FAST_INTERVAL_CEILING_IN_MILLISECONDS);

}
项目:LocationService    文件:LocationService.java   
@Override
public void onCreate() {
    Log.d(TAG, "onCreate()");

    super.onCreate();

    if (!servicesAvailable()) {
        stopSelf();
        return;
    }

    mLocationRequest = LocationRequest.create()
            .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
            .setInterval(15 * 60 * 1000)
            .setFastestInterval(1 * 60 * 1000);

    mLocationClient = new LocationClient(this, this, this);
    mLocationClient.connect();
}
项目:Dash    文件:WeatherExtension.java   
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    if (intent != null && ACTION_RECEIVED_LOCATION.equals(intent.getAction())) {
        final Location location = intent.getParcelableExtra(
                LocationClient.KEY_LOCATION_CHANGED);
        if (mServiceThreadHandler == null) {
            LOGW(TAG, "Can't process location update because onUpdateData hasn't been called "
                    + "on this service instance.");
        } else if (location != null) {
            // A location update request succeeded; try publishing weather from here.
            LOGD(TAG, "Got a Play Services location update; trying weather update.");
            mTimeoutHandler.removeCallbacksAndMessages(null);
            mServiceThreadHandler.post(new Runnable() {
                @Override
                public void run() {
                    tryPublishWeatherUpdateFromGeolocation(location);
                }
            });
        }

        stopSelf(startId);
    }

    return super.onStartCommand(intent, flags, startId);
}
项目:beeline    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    textLatLng = (TextView) findViewById(R.id.text_latlng);
    listLocations = (ListView) findViewById(R.id.list_locations);


    // configure location request
    mLocationRequest = LocationRequest.create();
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setInterval(UPDATE_INTERVAL);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
    mLocationRequest.setSmallestDisplacement(SMALLEST_DISPLACEMENT);

    // initialize location client
    mLocationClient = new LocationClient(this, this, this);

    // initialize database handler
    LocationEntryDbHelper dbHelper = new LocationEntryDbHelper(this);
    dbh = dbHelper.getReadableDatabase();

    initListView();
}
项目:appez-android    文件:LocationServiceOld.java   
@SuppressLint("HandlerLeak")
private void getCurrentLocation() {
    if (isLocationServiceEnabled) {
        handleLocationRequestTimeout();
        int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
        Log.d(SmartConstants.APP_NAME, "LocationService->play services:" + resp);
        if (resp == ConnectionResult.SUCCESS) {
            locationclient = new LocationClient(context, this, this);
            locationclient.connect();
            showProgressDialog();
            final LocationListener locListener = this;

            Handler locationHandler = new Handler() {
                @Override
                public void handleMessage(Message msg) {
                    locationrequest = LocationRequest.create();
                    locationrequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
                    locationrequest.setInterval(TIME_INTERVAL_BW_REQUESTS);
                    locationrequest.setNumUpdates(1);
                    locationclient.requestLocationUpdates(locationrequest, locListener);
                }
            };
            locationHandler.sendEmptyMessageDelayed(0, 1000);

        } else {
            onErrorLocationOperation(ExceptionTypes.LOCATION_ERROR_PLAY_SERVICE_NOT_AVAILABLE, ExceptionTypes.LOCATION_ERROR_PLAY_SERVICE_NOT_AVAILABLE_MESSAGE);
        }
    } else {
        // Means that the location service of the device is not turned on
        // Prompt the user to turn on the Location service
        showDecisionDialog("Location Service Disabled", "Location service is disabled in your device. Enable it?", "Enable Location", "No");
    }
}
项目:fme-apps-android    文件:MainActivity.java   
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_main);
   locationClient = new LocationClient(this, this, this);
   pref = PreferenceManager
         .getDefaultSharedPreferences(this);

   TypedArray styledAttributes = obtainStyledAttributes(new int[] { android.R.attr.selectableItemBackground });
   transparentBackground = styledAttributes.getResourceId(0, 0);
   styledAttributes.recycle();

   registerDeviceWithGCM();
   setUpNavigationDrawer();

   reportMarkers = new ArrayList<Marker>();
   alertMarkers = new ArrayList<Marker>();
   unsentMarkers = new ArrayList<Marker>();
   reportsFragment = new ReportsListFragment();
   alertsFragment = new AlertsListFragment();
   unsentFragment = new UnsentListFragment();
   prefsFragment = new MapPrefsFragment();
   fragmentManager = getFragmentManager();

   if (setUpMapIfNeeded()) {
      if (savedInstanceState == null) {
         initMapCamera();
      }
   }

   initWidgets();
   initToggleButton();
   FMEAlertsApplication.getInstance().updateMainActivityHandle(this);
   initMessageScreen();
   initLoaders(savedInstanceState);
   FMEApplication.getSuperInstance().isGPSEnabled(this);
}
项目:fme-apps-android    文件:FMEApplication.java   
@Override
public void onCreate() {
    super.onCreate();
    queueSend = false;
    prefs = PreferenceManager
            .getDefaultSharedPreferences(getApplicationContext());

    if(servicesConnected()){
    locationClient = new LocationClient(this, this, this);
    locationClient.connect();
    }
}
项目:yelo-android    文件:GooglePlayClientWrapper.java   
public GooglePlayClientWrapper(final AbstractYeloActivity activity, final LocationListener locationListener) {
    mActivity = activity;
    mLocationClient = new LocationClient(mActivity, this, this);

    mLocationListener = locationListener;
    mLocationRequest = LocationRequest
            .create()
            .setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
            .setInterval(UPDATE_INTERVAL)
            .setFastestInterval(FASTEST_INTERVAL);

    mLocationManager = (LocationManager) mActivity.getSystemService(Context.LOCATION_SERVICE);


}
项目:Emergency_Voice_Android_Application    文件:MyService.java   
@Override
public void onCreate() {
    super.onCreate();

    sharedpreferences = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
    outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/emergency.3gp";
    myAudioRecorder = new MediaRecorder();
    myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AMR_NB);
    myAudioRecorder.setOutputFile(outputFile);

    speech = SpeechRecognizer.createSpeechRecognizer(this);
    speech.setRecognitionListener(new recogListener());

    recognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en");
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE ,this.getPackageName());
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
    recognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 5);
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    mLocationClient = new LocationClient(this, this, this);
    if(Boolean.parseBoolean(sharedpreferences.getString("sendLocation","true"))) {
        connectToLocationService();
    }
}
项目:Pandora-sdk-android    文件:GeoService.java   
public void onCreate() { 
    super.onCreate();   
    geoService = this;

    int resp = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resp == ConnectionResult.SUCCESS) {
        locationclient = new LocationClient(this, connectionListener, this);
        locationclient.connect();
    } else {
        Toast.makeText(this, "Google Play Service Error " + resp,
                Toast.LENGTH_LONG).show(); 
    } 
}
项目:QuizUpWinner    文件:HomeActivityLocationHelper.java   
private void initLocation()
{
  this.locationRequest = LocationRequest.create();
  this.locationRequest.setInterval(60000L);
  this.locationRequest.setPriority(104);
  this.locationRequest.setFastestInterval(5000L);
  this.locationClient = new LocationClient(this.activity, this, this);
}
项目:GpsExample    文件:GpsService.java   
@Override
public void onCreate() {
    Log.d(TAG, "onCreate");
    this.locationRequest = new LocationRequest();
    if (hasFineLocationPermission())
        this.locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    else if (hasCoarseLocationPermission())
        this.locationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER);
    else
        this.locationRequest.setPriority(LocationRequest.PRIORITY_NO_POWER);

    this.locationRequest.setFastestInterval(FASTEST_INTERVAL);
    this.locationRequest.setInterval(FASTEST_INTERVAL);
    this.locationClient = new LocationClient(this, this, this);
}
项目:smart-city    文件:LocationManager.java   
public LocationManager() {
    super();

    mLocationClient = new LocationClient(Manager.activity(), this, this);

    mLocationRequest = LocationRequest.create();
    mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    mLocationRequest.setInterval(UPDATE_INTERVAL);
    mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
}
项目:CUMtd    文件:NearbyListFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLocationClient = new LocationClient(getActivity(), this, this);
    mListAdapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_list_item_1,
            android.R.id.text1);
    setListAdapter(mListAdapter);
}
项目:CUMtd    文件:BusMapFragment.java   
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mLocationClient = new LocationClient(getActivity(), this, this);
    try {
        mLoadingInterface = (LoadingInterface) getActivity();
    } catch (ClassCastException e) {
        throw new ClassCastException("Activity must implement LoadingInterface");
    }
}
项目:sharemyposition    文件:ShareByTracking.java   
@Override
public void onReceive(final Context context, final Intent intent)
{
    final NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    final LocationClient locationClient = new LocationClient(context, connectionCallbacks, onConnectionFailedListener);
    locationClient.registerConnectionCallbacks(new ConnectionCallbacks() {

        @Override
        public void onDisconnected()
        {
            Log.d(LOG, "StopTracking.onDisconnected");
        }

        @Override
        public void onConnected(Bundle arg0)
        {
            final PendingIntent service = PendingIntent.getService(context, 0,
                    new Intent(context, ShareByTracking.class), PendingIntent.FLAG_UPDATE_CURRENT);
            locationClient.removeLocationUpdates(service);
            locationClient.disconnect();
            notificationManager.cancel(R.string.app_name);
            Log.d(LOG, "StopTracking.onConnected");
        }
    });

    locationClient.connect();
}
项目:sharemyposition    文件:ShareByTracking.java   
@Override
public void onReceive(final Context context, final Intent intent)
{
    if (intent.getExtras().containsKey(UUID)) {
        final String uuid = intent.getStringExtra(UUID);
        final LocationClient locationClient = new LocationClient(context, connectionCallbacks, onConnectionFailedListener);
        locationClient.registerConnectionCallbacks(new ConnectionCallbacks() {

            @Override
            public void onDisconnected()
            {
                Log.d(LOG, "StartTracking.onDisconnected");
            }

            @Override
            public void onConnected(Bundle arg0)
            {
                final LocationRequest locationRequest = LocationRequest.create()
                        .setSmallestDisplacement(SMALLEST_DISPLACEMENT)
                        .setInterval(INTERVAL)
                        .setPriority(PRIORITY);
                final PendingIntent service = PendingIntent.getService(context, 0, new Intent(context,
                        ShareByTracking.class).putExtra(UUID, uuid), PendingIntent.FLAG_UPDATE_CURRENT);
                locationClient.requestLocationUpdates(locationRequest, service);
                locationClient.disconnect();
                Log.d(LOG, "StartTracking.onConnected");
            }
        });

        locationClient.connect();
    }
}
项目:sharemyposition    文件:ShareMyPosition.java   
@Override
protected void onStart()
{
    super.onStart();
    if (isGooglePLayServicesAvailable()) {
        this.mLocationClient = new LocationClient(this, this, this);
    } else {
        Toast.makeText(this, R.string.no_play_service, Toast.LENGTH_LONG).show();
        finish();
    }
}
项目:findyourhappyplace    文件:BrainwaveValuesActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.setContentView(R.layout.main);

    this.museReceiver = new MuseIOReceiver();
    this.museReceiver.registerMuseDataListener(this);
       mLocationClient = new LocationClient(this, this, this);
}
项目:AndroidLocationHub    文件:GMSLocationHubAdapter.java   
@Override
protected void setup(Context context, ConnectionCallbacks callbacks, OnConnectionFailedListener connectionFailedListener, Bundle bundle) {
    GMSConnectionCallbacksImpl realConnectionCallbacks = putConnectionCallbacks(callbacks);
    GMSOnConnectionFailedListenerImpl realConnectionFailedListener = putConnectionFailedListener(connectionFailedListener);

    mLocationClient = new LocationClient(context,
            realConnectionCallbacks,
            realConnectionFailedListener);
}
项目:p2psafety    文件:LocationService.java   
@Override
public void onCreate() {
    super.onCreate();

    mLocationClient = new LocationClient(this, this, this);
    locationListener = new AWLocationListener();
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    mEventManager = EventManager.getInstance(LocationService.this);
}