How to set Google Analytics api key programmatically? - android

I can't find how to do this. There's this documentation: https://developers.google.com/analytics/devguides/collection/android/v2/advanced - it shows this method:
gaInstance.getTracker(trackingId)
Where trackingId is the api key, but I think this can be used only after the tracker is already configured right? It's not to set the api key.
I need this, because my app has to track to different accounts, depending of a certain server configuration. The server will send me the api key where to track to.
Thanks in advance.
P.S. I'm using Google Analytics V2.

I did this:
GoogleAnalytics gaInstance = GoogleAnalytics.getInstance(context);
Tracker gaTracker = gaInstance.getTracker(apiKeyGA);
gaInstance.setDefaultTracker(gaTracker);
Seems to work. I have to confirm although.
I put it somewhere after initialization, after my webservice returns. I save it in prefs to access quicker the next time.
Edit: Doesn't work. It keeps tracking with the string I put in XML, and when I remove the element, it doesn't track anymore. But I let it here for now, maybe it leads to a correct answer.

Related

Leaked GCP API Keys : Your app contains exposed Google Cloud Platform (GCP) API keys. Please see this Google Help Center article for details

I am getting this error from Play Store:
I tried to limit the access of API key within that file but still getting this error. How can I solve this?
Make sure that keys are not leaked via sites such as GitHub.
Notice the message wording "Your app contains exposed ...". That message did not say your app is exposing the keys.
You will need to delete the key and create a new key, update your app, etc.
Delete current key and create new one. Also make sure you apply restrictions like HTTP referrers, IP Address restrictions etc. based on your use case. For more info, check this
https://cloud.google.com/docs/authentication/api-keys#api_key_restrictions
The error is due to the API key being included in your source code. Consider using Google's Secrets Gradle Plugin for Android to hide your API keys from source code. Documentation at https://github.com/google/secrets-gradle-plugin and demo by the author at https://youtu.be/X8lYNW_Or2o

Can't set Google Account Credential in Android

I'm trying to use the Google Drive REST API - using the exact sample code found at Android REST Quickstart. However I cannot set an account name for the Google Account Credential object in the the onActivityResult method.
I don't get it as I've triple checked that mCredential.setSelectedAccountName(accountName); is definitely being passed an email string for the account name, but when I try and use mCredential.getSelectedAccountName() it always returns null immediately after it has supposedly been set. This means that the account picker is constantly being called but never sets an account name.
Someone please help as this is driving me crazy!
If You are running your application on android version 6.+ then make sure that your app has all the required permission allowed. You can check this by going Setting->apps->your_app->apps permission.

Request public Google+ profile data

I'm searching the PlayServices equivalent of this call:
https://www.googleapis.com/plus/v1/people/<some_user_id>?key=<your_api_key>
The call above is documentation of the call above is here: https://developers.google.com/+/web/api/rest/latest/people/get
However this is a web API call and my keys are restricted to a limited set of IPs. I think it would be a bad idea to put that key in code. Do you think the same?
Just as a side note I would like get the data without "authorization". I mean I authenticate with my key, but I don't want to ask the user. With the HTTP call above this is possible, so what is the Android SDK equivalent? I'm not asking how to do the GoogleApiClient stuff I have this already working. I just want to know the right call of the plus API.
If there is nothing similar do you know how to authenticate myself at the rest service with my packagename and signature?
In summary I just want to know the (first and last) name of the local G+ accounts like in the Google Foto app.
To load a specific Google+ profile in Android use the load method for com.google.android.gms.plus.People.
public abstract PendingResult<People.LoadPeopleResult> load (GoogleApiClient googleApiClient, String... personIds)

Disable iOS and Android App from App store and google play store with custom message to users

Is there a way to disable iOS and Android apps which are live, for a few hours and add some custom message to all users, Can this be done through itunesconnect for Apple or google developer console for andorid.
Note :- i dont want to release new Apps / change existing code.
max
I know you mentioned you don't want to release new apps or change existing code, but unfortunately for this level of customization you'll have to (to start!) There's no push of a button to do this for you for either dashboard.
There's multiple ways of doing this and there's no official documentation out there, so if this answer gets accepted by the OP still look around at other answers on this thread.
My approach is to listen to an endpoint that you create, may it be from dropbox, s3, parse, etc. that have certain key-value pairs that your application can retrieve and handle appropriately. To the level of customization is up to you.
Let's do the example of your "we're temporarily unavailable" idea. Have the endpoint do the following:
{
"unavailable" : false,
"unavailable_text" : "Sorry we'll be back shortly!"
}
Now on app start up you listen to this endpoint. One day the unavailable key will be true, when that happens in the success handler for the endpoint you'll put in some logic to present a UnavailableViewController of sorts that might have a UILabel called descriptionLabel
if ([json valueForKey:#"unavailable"]) {
UnavailableViewController* controller = [[UnavailableViewController alloc] init];
controller.descriptionLabel.text = ([json valueForKey:#"unavailable_text"]) ? [json valueForKey:#"unavailable_text"] : #"We're temporarily unavailable, please try again later."; // just in case you forget to set it have a fallback.
// present view controller...
}
Hope this helps! Let me know in comments of any questions/concerns.

How to get Ola Cabs Api key?

I need to implement Ola cabs Api in an android app. I am following this link - http://docs.console.olacabs.com/ola.
But everytime I try and fetch some data, it says "Authorization Error". I need a valid Api key to use the services but can't find a way or link to generate one.
try #ndo1d
http://blog.attify.com/2015/02/01/ola-cabs-privacy-security-issue-discovered-appwatch/
https://medium.com/#CodeTheDevil/busting-ola-wallet-1ceea6174b1f
You can use the application normally, and AppWatch will show you the real time application’s network traffic. AppWatch is an intelligent platform, with which it automatically identifies APIs which could be vulnerable. As soon the app does something which AppWatch identifies to be vulnerable, it simply displays a vulnerable tag along with the request.
Usually you have to insert an API Key in the header of the request to access API's functions.
I don't know exactly if it's the case, or if you have generated the API Key, if this key has authorization to access the resource you want.
Please check: Do you have an API Key? Does it provide access to what resources?
ps: I can't comment. That's why I wrote an answer.
Register here to get API Key..
https://developers.olacabs.com/docs/ride-availablity

Categories

Resources