0

I am developing an android app that use google places api but i am getting a NETWORK_ERROR status and status code 7

here is my code :

private GoogleApiClient mGoogleApiClient;


     @Override
    protected void onStart() {
        super.onStart();
          if( mGoogleApiClient != null )
                mGoogleApiClient.connect();
    }

     @Override
     protected void onStop() {
         if( mGoogleApiClient != null && mGoogleApiClient.isConnected() ) {
                mGoogleApiClient.disconnect();
            }
            super.onStop();
     }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, 0, this)
                .addApi(Places.GEO_DATA_API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this).build();

    }


    @Override
    public void onConnectionFailed(ConnectionResult result) {
        Toast.makeText(getApplicationContext(), "Connection Failed", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onConnected(Bundle arg0) {
        Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_SHORT).show();
        System.out.println("add place>>>>>");
        System.out.println("add place>>>>>");
        System.out.println("add place>>>>>");
        System.out.println("add place>>>>>");
        try {
            addPlace();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    @Override
    public void onConnectionSuspended(int arg0) {
        Toast.makeText(getApplicationContext(), "sConnection Suspended", Toast.LENGTH_SHORT).show();

    }

    private void addPlace() {
        AddPlaceRequest place =
                new AddPlaceRequest(
                        "My Custom Place", // Name
                        new LatLng(38.124606, 30.652658), // Latitude and longitude
                        "test address", // Address
                        Collections.singletonList(Place.TYPE_AQUARIUM),// Place types
                        "+1 650-253-0000" // phone nb
                );



        Places.GeoDataApi.addPlace(mGoogleApiClient, place)
                .setResultCallback(new ResultCallback<PlaceBuffer>() {
                    @Override
                    public void onResult(PlaceBuffer places) {
                        System.out.println("places.getStatus().getStatus()>>>>>"+places.getStatus().getStatus());
                        System.out.println("places.getStatus().getStatusCode()>>>>>"+places.getStatus().getStatusCode());
                        System.out.println("places.getStatus().getStatusMessage()>>>>>"+places.getStatus().getStatusMessage());
                        System.out.println("places.getStatus().isSuccess()>>>>>"+places.getStatus().isSuccess());
                        System.out.println("places.getStatus()>string>>>>"+places.getStatus().toString());
                        places.release();
                        Toast.makeText(getApplicationContext(), "place added", Toast.LENGTH_SHORT).show();
                    }
                });
    }

manifest :

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

and here is my application tag i creaated the api key for google places and is enabled and the two meta-data tags : com.google.android.gms.version and com.google.android.geo.API_KEY

Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
Tanos
  • 29
  • 4
  • http://stackoverflow.com/questions/29845946/google-places-api-for-android-error-statusstatuscode-network-error-resolution here you can consult people with similar problem. – Distopic Jan 26 '16 at 08:18
  • http://stackoverflow.com/questions/15195264/google-plus-unable-to-load-person here you have some issue resolved too. – Distopic Jan 26 '16 at 08:18
  • i checked them it wasn't helpful i am enabling the google places api for android in the console and have a key and exported the app plus have the exact package name and SHA-1 and still getting NETWORK_ERRO – Tanos Jan 26 '16 at 08:34

0 Answers0