当前位置: 首页>>代码示例>>Java>>正文


Java LocationClient类代码示例

本文整理汇总了Java中com.google.android.gms.location.LocationClient的典型用法代码示例。如果您正苦于以下问题:Java LocationClient类的具体用法?Java LocationClient怎么用?Java LocationClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LocationClient类属于com.google.android.gms.location包,在下文中一共展示了LocationClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MyTracksLocationManager

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
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);
}
 
开发者ID:Plonk42,项目名称:mytracks,代码行数:21,代码来源:MyTracksLocationManager.java

示例2: applicationStartup

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
/**
 * @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);
}
 
开发者ID:emuneee,项目名称:nc-traffic-cams-open,代码行数:28,代码来源:MainActivity.java

示例3: onCreate

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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);
}
 
开发者ID:codeforgreenville,项目名称:trolley-tracker-agent,代码行数:19,代码来源:BackgroundLocationService.java

示例4: onHandleIntent

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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() );
	}
}
 
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:20,代码来源:GeofencingService.java

示例5: onCreate

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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();
			}
		}
	});
}
 
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:24,代码来源:MainActivity.java

示例6: setMockLocation

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
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();
}
 
开发者ID:headdetect,项目名称:MockLocation,代码行数:27,代码来源:MainActivity.java

示例7: onHandleIntent

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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));
        }
    }

}
 
开发者ID:sylvek,项目名称:sharemyposition,代码行数:20,代码来源:ShareByTracking.java

示例8: onCreate

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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(); }
    });
}
 
开发者ID:Gyebro,项目名称:android-demos,代码行数:20,代码来源:MainActivity.java

示例9: onCreate

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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);
}
 
开发者ID:abakiaydin,项目名称:LocationUpdates,代码行数:21,代码来源:MainActivity.java

示例10: onCreate

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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);
}
 
开发者ID:bobzoller,项目名称:trigger.io-background_geolocation,代码行数:23,代码来源:BackgroundLocationService.java

示例11: addGeofences

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
/**
 * 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();
    }
}
 
开发者ID:mauimauer,项目名称:AndroidWearable-Samples,代码行数:28,代码来源:MainActivity.java

示例12: onCreateView

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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;
}
 
开发者ID:smo-key,项目名称:sohacks,代码行数:19,代码来源:CampingFragment.java

示例13: onCreateView

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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;
}
 
开发者ID:smo-key,项目名称:sohacks,代码行数:21,代码来源:ParksFragment.java

示例14: onCreate

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
@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);
	}

}
 
开发者ID:gvellut,项目名称:Android_OSM_offlinemap,代码行数:26,代码来源:MainActivity.java

示例15: LocationRetriever

import com.google.android.gms.location.LocationClient; //导入依赖的package包/类
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;


}
 
开发者ID:mustafaneguib,项目名称:tag-augmented-reality-android,代码行数:21,代码来源:LocationRetriever.java


注:本文中的com.google.android.gms.location.LocationClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。