How to use Google's auto complete places api in Android application - android

I want to use Google Places API in my android application. I have API Key I got it from Google's API console. I am following the Perform Autocomplete section in this tutorial.
Now the problem I am facing is exactly which jar file I need for this. I have tried with two:
google-api-client-1.6.0-beta.jar
In this case I am getting exception when creating the object of class where I have implemented these methods and imported the packages of above library
google-http-client-1.6.0-beta.jar
GoogleHeaders cannot be resolved to a type
If I comment the code where I am setting header to request it does not shows any error but
when I execute the code I get the following error:
java.lang.NoClassDefFoundError: com.google.common.base.Preconditions
I have also added all the dependency jars.

There is no need to use a specific client. Just use any library that can make HTTP requests (like Apache HttpClient), then parse the JSON (or XML) that you get back from the Places API.

Related

Firebase Management API projects.addFirebase permission denied

Problem: Firebase Management API method projects.addFirebase returns status code 403
Steps to recreate:
In an Android application I need to create separate Firebase Accounts for Realtime Database. For this purpose I authenticate users with GoogleSignIn.
Then I retrieve token with proper scope "oauth2:https://www.googleapis.com/auth/cloud-platform".
In next step I use GCP Resource Manager API to create a new GCP project, which will be a container for Firebase project.
The new project is created successfully on each of the test accounts.
When I try to call Firebase Management API method projects.addFirebase using the same token I got earlier (same scope) I get error "The caller does not have permission". This error occurs on 3 out of 4 accounts I have tried.
I was able to reproduce same error also using google-apis-explorer. Apis Explorer
I will be grateful for any hints on how to resolve this issue. As I mentioned earlier this error does not occur on one of the accounts I tested, while on the remaining three it happens every time.
Thank you.
Update
#Doug thank you for taking time to look at my problem. It seems that I have found the cause. After accessing https://console.firebase.google.com and clicking "Add a project" a following popup showed up (I can't paste it directly, because my reputation is too low):
Popup link
After I checked all consents and added first project I am also able to make api calls successfully.
It looks like I my question should be: Is there a way to grant required permissions through Resource Manager Api calls so I can add Firebase to existing Cloud Project?
Also for the reference I paste the method I use to call projects.addFirebase, it uses RxJava2 (Android) and Retrofit2.
#Headers({"Content-Type: application/json"})
#POST("projects/{project}:addFirebase")
Single<Operation> addFirebaseToProject(#Header("Authorization") String bearerToken,
#Path("project") String project,
#Body FirebaseDataModel dataModel
);
Thank you for your help.
Ps. sorry for my bad English, it's not my mother tongue.

How can I search for restaurants using filters with google maps android api?

I'm trying to make an app that finds the users location and then searches for for example nearby restaurants. I have a method to find the users location the only thing that is left is to find the restaurants nearby the user. How can I do this? Plz Help!
I don't know about any native android soultions but you can make a Get request to this Google Places API webservice
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=8.5586,76.8814&radius=500&types=food&sensor=false&key=[Your_KEY]
And parse the Json to get the restaurants nearby
location - Latitude,Longitude of the place
radius - Required radius to search your request
key - Your API Key
types - Types of places to search
Things to do to parse the results
Get an Api key and create a sample request in the browser, You will get a big json result something like this
Goto websites like this which can generate POJO classes for your Json the best configuration is given below:
Download files and extract it and add them to your source code,You will get some errors at first because you may not have the annotation libraries in your build.gradle
Add these lines in your app's build.gradle:
dependencies{
compile 'com.google.code.gson:gson:2.3.1'
compile 'javax.annotation:javax.annotation-api:1.2-b01'
}
Sync gradle files,And In the code where you get the json String ,deserialize it with Gson like:
YourGooglePlacesClass object=new Gson().fromJson(jsonString,YourGooglePlacesClass.class)
You can check out the PlacePicker API that's native uses the Google Places API for Android. For samples, Google provided it in their googlesamples github repo, you can check those out!

Provide link to fetch Google Calendar(Online) events in Android application

I am trying to fetch events from Google Calendar(Online) using Google Calendar API's in Android application but can't find what library need to import in my Android project. Provide link to import exact library to import in my Android application project.
You can use Google Calendar API directly importing to your project. By using that you can create, view, edit and delete any activity.
For more info see this following page.
https://developers.google.com/google-apps/calendar/
u can either use rest,client libraries to access google calendar api's ... client api will be size overhead .. so better use rest calls ... here is the link which explains rest calls and json parsing ...http://www.androidhive.info/2012/01/android-json-parsing-tutorial/

CreateWalletObjectsRequest is missing from com.google.android.gms.wallet API

As per the given link: https://developers.google.com/wallet/objects/savetowalletnative
I am trying to run the sample application, but in this below method, I am not able to find CreateWalletObjectsRequest. It says:
"CreateWalletObjectsRequest cannot be resolved to a type"
public void saveToWallet(View view){
LoyaltyWalletObject wob = generateObject();
CreateWalletObjectsRequest request = new CreateWalletObjectsRequest(wob);
Wallet.createWalletObjects(googleApiClient, request, SAVE_TO_WALLET);
}
Google hasn't opened Save to Wallet api for everyone yet. We had to get a special Google Play Services AAR directly from Google, along with a lot of help from a Googler to get it functioning (the sample is out of date).
As of now, you'll need to work with your Google contact to get the second-party library to integrate Android Pay. Once you get the aar file, you can import it into your project and add it as a dependency.
Now, the 'createWalletObjects' method call in your question has shifted in its location and signature; its now as follows:
Wallet.WalletObjects.createWalletObjects(googleApiClient, request, SAVE_TO_WALLET);
The SAVE_TO_WALLET is the integer request code that you'll identify the request in your onActivityResult(). Creating the request as such is described in the "Create an object" section of https://developers.google.com/save-to-android-pay/guides/android/add-button-to-your-app

Tumblr integration in android

In my app I want to integrate tumblr and getting photos from tumblr. On Github I have found "TumblrExample". In this sample I have replaced my consumer key and consumer secret and when I run this app I am getting following exception:
dalvikvm :Could not find class 'oauth.signpost.commonshttp.CommonsHttpOAuthConsumer', referenced from method com.robertszkutak.androidexamples.tumblrexample.TumblrExampleActivity.<clinit>
java.lang.VerifyError: com/robertszkutak/androidexamples/tumblrexample/TumblrExampleActivity
I have studied full documentation of tumblr api. In that api all webservices available to get the data. To get the photos from tumblr api the following websevice is useed:
http://api.tumblr.com/v2/blog/{hostname}/posts?api_key={consumer key}&type=photo
How can I authorise and get the hostname programatically?
I also getting same problem in same sample i.e "TumblrExample". But, I replace signpost-commonshttp4.jar, signpost-core.jar with latest and also i change version i.e 1.6 to 2.3 its works perfect.
Use signpost-commonshttp4.jar and signpost-core.jar from here:
https://code.google.com/p/oauth-signpost/downloads/list

Categories

Resources