Sample code for 30+ languages & platforms
Android™

Google People API - Delete a Contact

See more Google People Examples

Demonstrates how to delete a People API Contact.

Chilkat Android™ Downloads

Android™
// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    boolean success = false;

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    // It is assumed we previously obtained an OAuth2 access token.
    // This example loads the JSON access token file 

    CkJsonObject jsonToken = new CkJsonObject();
    success = jsonToken.LoadFile("qa_data/tokens/googlePeople.json");
    if (success != true) {
        Log.i(TAG, "Failed to load googleContacts.json");
        return;
        }

    CkHttp http = new CkHttp();

    http.put_AuthToken(jsonToken.stringOf("access_token"));

    // Send the following request, where resource_name contains the actual resource name, such as "people/c172365763025317520".
    // DELETE /v1/resource_name:deleteContact 

    String responseText = http.quickDeleteStr("https://people.googleapis.com/v1/people/c172365763025317520:deleteContact");
    if (http.get_LastMethodSuccess() == false) {
        Log.i(TAG, http.lastErrorText());
        return;
        }

    // A 200 status code indicates success.  The response text for success will be an empty JSON document: "{}"
    Log.i(TAG, "Response status code = " + String.valueOf(http.get_LastStatus()));
    Log.i(TAG, "Response text:");
    Log.i(TAG, responseText);

  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}