Android ActivityRecognitionClient - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android ActivityRecognitionClient class.

This code example shows how to use the following methods:disconnect, removeActivityUpdates
	 
	@Override 
	protected void onDestroy() { 
		super.onDestroy(); 
		if(arclient!=null){
			arclient.removeActivityUpdates(pIntent);
			arclient.disconnect();
		} 
		unregisterReceiver(receiver);
	} 
	 
	@Override 
	public void onConnectionFailed(ConnectionResult arg0) {
		Toast.makeText(this, "Connection Failed", Toast.LENGTH_SHORT).show();
	} 
	@Override 
	public void onConnected(Bundle arg0) {
		Intent intent = new Intent(this, ActivityRecognitionService.class);
		pIntent = PendingIntent.getService(this, 0, intent,PendingIntent.FLAG_UPDATE_CURRENT);
		arclient.requestActivityUpdates(1000, pIntent);   
5
CodeRank
This code example shows how to use the following methods:disconnect, isConnected, removeActivityUpdates
    @Override 
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        if (isChecked) {
            mClient.connect();
        } else { 
            if (mClient == null || !mClient.isConnected()) {
                return; 
            } 
 
            mClient.removeActivityUpdates(mPendingIntent);
            mClient.disconnect();
        } 
 
        PreferenceManager.getDefaultSharedPreferences(this).edit()
                .putBoolean("service", isChecked).commit();
    } 
 
    @Override 
    protected void onDestroy() { 
        super.onDestroy(); 
5
CodeRank
This code example shows how to use the following methods:
    private ActivityRecognitionClient getActivityRecognitionClient()
    { 
        if (mActivityRecognitionClient == null)
        { 
            mActivityRecognitionClient =
                    new ActivityRecognitionClient(mContext, this, this);
        } 
 
        return mActivityRecognitionClient;
    } 
 
 
    /** 
     * Get the current activity recognition client and disconnect from Location Services 
     */ 
    private void requestDisconnection() 
    { 
        getActivityRecognitionClient().disconnect();
    } 
 
3
CodeRank
This code example shows how to use the following methods:
     */ 
    private ActivityRecognitionClient getActivityRecognitionClient() {
        if (mActivityRecognitionClient == null) {
 
            mActivityRecognitionClient =
                    new ActivityRecognitionClient(mContext, this, this);
        } 
        return mActivityRecognitionClient;
    } 
 
    /** 
     * Get the current activity recognition client and disconnect from Location Services 
     */ 
    private void requestDisconnection() { 
        getActivityRecognitionClient().disconnect();
    } 
 
    /* 
     * Called by Location Services once the activity recognition client is connected. 
     * 
4
CodeRank
This code example shows how to use the following methods:
     */ 
    private ActivityRecognitionClient getActivityRecognitionClient() {
        if (mActivityRecognitionClient == null) {
 
            mActivityRecognitionClient =
                    new ActivityRecognitionClient(mContext, this, this);
        } 
        return mActivityRecognitionClient;
    } 
 
    /** 
     * Get the current activity recognition client and disconnect from Location Services 
     */ 
    private void requestDisconnection() { 
        getActivityRecognitionClient().disconnect();
    } 
 
    /* 
     * Called by Location Services once the activity recognition client is connected. 
     * 
4
CodeRank
This code example shows how to use the following methods:
     */ 
    private ActivityRecognitionClient getActivityRecognitionClient() {
        if (mActivityRecognitionClient == null) {
 
            mActivityRecognitionClient =
                    new ActivityRecognitionClient(mContext, this, this);
        } 
        return mActivityRecognitionClient;
    } 
 
    /** 
     * Get the current activity recognition client and disconnect from Location Services 
     */ 
    private void requestDisconnection() { 
        getActivityRecognitionClient().disconnect();
    } 
 
    /* 
     * Called by Location Services once the activity recognition client is connected. 
     * 
4
CodeRank
This code example shows how to use the following methods:
     */ 
    private ActivityRecognitionClient getActivityRecognitionClient() {
        if (mActivityRecognitionClient == null) {
 
            mActivityRecognitionClient =
                    new ActivityRecognitionClient(mContext, this, this);
        } 
        return mActivityRecognitionClient;
    } 
 
    /** 
     * Get the current activity recognition client and disconnect from Location Services 
     */ 
    private void requestDisconnection() { 
        getActivityRecognitionClient().disconnect();
    } 
 
    /* 
     * Called by Location Services once the activity recognition client is connected. 
     * 
4
CodeRank
This code example shows how to use the following methods:
	 *  
	 * @return An ActivityRecognitionClient object 
	 */ 
	private ActivityRecognitionClient getActivityRecognitionClient() {
		if (mActivityRecognitionClient == null) {
			mActivityRecognitionClient = new ActivityRecognitionClient(mContext, this, this);
		} 
		return mActivityRecognitionClient;
	} 
 
	/** 
	 * Get the current activity recognition client and disconnect from Location 
	 * Services 
	 */ 
	private void requestDisconnection() { 
		getActivityRecognitionClient().disconnect();
	} 
 
	/* 
	 * Called by Location Services once the activity recognition client is 
4
CodeRank
This code example shows how to use the following methods:connect
    } 
 
    @Override 
    protected void onStart() { 
        super.onStart(); 
        activityRecognitionClient = new ActivityRecognitionClient(this, this, this);
        activityRecognitionClient.connect();
    } 
 
    @Override 
    public void onConnected(Bundle bundle) {
        Intent intent = new Intent(this, ActivityRecIntentService.class);
        PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        activityRecognitionClient.requestActivityUpdates(FIVE_MINUTES, pendingIntent);
    } 
 
    @Override 
    public void onDisconnected() { 
    } 
5
CodeRank
This code example shows how to use the following methods:
         * 
         */ 
        if (mActivityRecognitionClient == null)
        { 
            // Create a new one 
            setActivityRecognitionClient(new ActivityRecognitionClient(mContext, this, this));
        } 
 
        return mActivityRecognitionClient;
    } 
 
 
    /** 
     * Get a activity recognition client and disconnect from Location Services 
     */ 
    private void requestDisconnection() 
    { 
        // Disconnect the client 
        getActivityRecognitionClient().disconnect();
 
4
CodeRank

Related Android ActivityRecognitionClient Questions & Answers:

See Code Examples for Android ActivityRecognitionClient Methods: