what does these methods Means in android studio in google map
1).OnMapReadyCallback
2). LocationListener
3). GoogleApiClient.ConnectionCallbacks
4). GoogleApiClient.OnConnectionFailedListener
from Android Developer docs:
LocationListener
public interface LocationListener
android.location.LocationListener
Used for receiving notifications from the LocationManager when the location has changed
it is just like using OnClickListener to detect a user's click, but it listens for changes in location. you can use it to perform a set of instruction when the user have localisation enabled and moves to another location.
GoogleApiClient is The main entry point for Google Play services integration, is what you use to connect the client (user, to the google play services
GoogleApiClient.OnConnectionFailedListener public static interface
GoogleApiClient.OnConnectionFailedListener Provides callbacks for
scenarios that result in a failed attempt to connect the client to the
service.
it is used to define what should happen (just a set of instructions), in case your attempt to connect to the google play services has failed
GoogleApiClient.ConnectionCallbacks public static interface GoogleApiClient.ConnectionCallbacks Provides callbacks that are
called when the client is connected or disconnected from the service
this is very similar to the previous one, but instead of defining what should be done when a the client fails to connect, it defines what should be done, when a connection to the google play services is successfully established, or if a disconnection with the services has been preformed.
as for the rest :
i got this information from the documentation,
i invite you to read it before posting, it contains all the information that you may need, and try to implement the methods your self to understand how they work
Related
I have created an HTTP Google Cloud Function that does not allow unauthenticated requests.
I have created a service account in the project with one role: Cloud Functions Invoker.
This service account is listed as a principal for my http cloud function and shows to have that role:
I have created a Cloud Scheduler Job to run this function.
In the job, I've specified that I want it to obtain an OIDC token for authenticating requests to the http function:
Whenever I trigger the job, it fails with a message indicating the request is unauthenticated:
Things I've tried:
Recreate the function
Recreate the job
Use a different user (the main service account user - that one doesn't work either)
Do a POST instead of a GET from the scheduler job (I've successfully created scheduled jobs for authenticated http functions before but this is the first time I've done a GET - just grasping at straws really)
Did I miss something? Any idea why it is coming back with the "Unauthenticated" message?
I revisited this today. My IAP protected HTTP function is expecting a query string parameter to be passed into it. The Cloud Platform Web UI automatically sets the audience to the same URL (including the parameter) when creating the Scheduled Job. I figured Google knows what they are doing, so I left it that way originally.
Out of desperation I tried removing this parameter from the audience and that made the authentication work properly.
So, I changed the audience from
https://<myProject>.cloudfunctions.net/myFunction?p=abc
to
https://<myProject>.cloudfunctions.net/myFunction
Has anyone tried to Import an (private and not publicly accessible) API App as an API when your API management instance is deployed in a vnet? This is different than just pointing to an ip address like explained here, which no doubt will work.
However, directly pointing to an Azure resource, as the Import API App does, seems like the nicer approach. I wonder what the exact requirements are, as I've tried to import an API app that wasn't part of the same vnet, and it gave a DNS error after importing the API and trying it out in API Management (which only makes sense if it tried to call the API App as if it's hosted on the internet, if the API App is accessible from the internet, there is no issue, that works perfectly).
There is a direct reference between an API resource and the API Management resource (it sets the ResourceId on your ApiManagementBackend). Also, I've set HostNamesDisabled to true on the API App, which speficially claims that "the app is only accessible via API management process"... So Azure should handle the traffic between the two resources internally right (this is what i hoped)?
Trying to put both resources in the same vnet would be the next thing to try, but then i'd skip the whole Import API all together because then i can just point to the ip address. Which perhaps concludes that the Import API functionally is not beneficially in an API Management vnet scenario?
The best approach for me at the moment is to not put the API app in a vnet, and just disable access to the API app for all ip's except for the public endpoint of the API management instance.
After private endpoints become generally available for app services I might reevaluate this...
I use serverless framework to manage my cloud functions. Some of them are of HTTP type. Recently, all the HTTP functions started to fail with 403 error. No matter if you enter a URL in a browser or trigger it with the cloud scheduler. The only place where it works is the testing tab of the function in the cloud console, when you click the "Test the function" button.
So, I did not find the reason for the error but it fixed with removing the function and redeploying it.
serverless remove
serverless deploy
Is it possible that the Identity Aware Proxy has been enabled for the Cloud Function URLs? If you navigate to Cloud Console and then to "Security" and "Identity-Aware Proxy", you should be able to see the IAP settings and whether the Cloud Function is being protected by IAP.
If that is not the cause, I would advise putting some logging in your function that would make it clear whether the function is getting called and then returning a 403 somewhere within the execution of the function (indicating a problem with the function, itself, rather than the identity infrastructure) or if the function is never getting called (the 403 is being produced outside of the Cloud Function), in which case you may need to reach out to Cloud Support for help with this (if IAP isn't the cause).
Google Cloud Functions added some new IAM functionality, not sure how recently, and now new functions don’t have public access by default.
Incase someone else comes here I thought I'd share this information here.
To allow your function to be invoked you first have to add permissions to the function, you can do this by selecting the function in the functions list and adding allUsers to the Cloud Invokes role, you can see the step by step at:
https://lukestoolkit.blogspot.com/2020/06/google-cloud-functions-error-forbidden.html
I have an android application where Im uploading a file to Google Drive. First I load an activity and let a user make some choises, then I start an service that uploads the file in the background. As I understand I need to create the GoogleApiClient in an activity to be able to launch the authorization screens. How Im i supposed to get the then authorised GoogleApiClient to my background service?
You can instantiate the GoogleApiClient in the Activity once in order to ensure that the user has selected an account and authorized your app. Once they have done that once, they shouldn't need to do it again.
At that point you can create a new GoogleApiClient in your service and be fairly confident it will succeed. If it fails, you could always throw up a notification or some such indicating the user needs to take action.
That said, you shouldn't need a background service just to write a file. Since the actual upload will happen in the background already, all you need to do is write to the Contents in an AsyncTask.
I had the same problem...
I solve it by making part of my configuration activity the login to google (check if google play is installed, register and then connect). The activity asks for my google account and password.
My service then don't have problems with connect. I also find that I only have to supply my google login and password once. When I restart my app and I start the configuration activity, it connect to the drive SDK without asking my google login and password
I'm writing a chromecast receiver application that will (hopefully) allow me to remotely put alert messages up on my TV to serve as reminders.
My plan was to have a dedicated wireless device on my home network that would constantly poll for new messages from a centralized server. When a new message was found, it would connect to a chromecast route, turning on the TV and displaying the new message.
But as far as I can tell, the only way to activate a chromecast route is by manually clicking the chromecast icon on my Chrome browser or wireless device.
Is there a way, programmatically, to activate the chromecast? Can it be done in the sender?
You can programmatically scan for cast devices and connect to them if needed. Steps are:
Get an instance of the MediaRouter singleton from the system: mMediaRouter
Build a selector:
mMediaRouteSelector = new MediaRouteSelector.Builder()
.addControlCategory(
CastMediaControlIntent
.categoryForCast(YOUR_APP_ID)).build();
Add a callback to initiate scan:
mMediaRouter.addCallback(mMediaRouteSelector, mMediaRouterCallback,
MediaRouter.CALLBACK_FLAG_PERFORM_ACTIVE_SCAN);
The onRouteAdded() and onRouteRemoved() of your callback (i.e. mMediaRouterCallback) will be called as routes are discovered or removed. You can maintain a list of routes in your app and keep them up to date by using these two callbacks.
You can select a route by calling mMediaRouter.selectRoute(aRouteInfo). Then the onRouteSelected() of your callback will be called and you can extract the cast device as usual and do as you please.
These said, remember that if you want to show a notification to users on TV your app should be running on the chromecast at the time you want to send the notification.