Access GeoJSON-String with Esri REST-API in Android with Token - android

I have been stuggeling wiht that for a while and found no working solution:
I want to get a GeoJSON-String from an own ArcGIS Web Server. I want to use the REST-API and got it working in the browser. I just have to type in my username and password and after my authentification i can use the link to get the GeoJSON-String.
In Android I tried it with different solutions, one - of course - was to follow the instructions on the Esri-Website. Here they explain how to set the Username and the Password to create a UserCredential. The UserCredential now is passed to the Method to create a new ArcGISDynamicMapServiceLayer together with the REST-Link. So they get a new Layer, but there is no method, where you can pass the UserCredential and the Link to get just a String.
Because I want to get polygons I thought, that the ArcGISFeatureLayer could help me out. But if I pass the given User-Informations and the Link i just get back an null-Objekt.
Here is a snippet of my most-hopefull code:
String url = "https://domain.de/arcgis/rest/services/FeatureEditor/FeatureEditor/FeatureServer/13/query?where=fahrzeug_id+%3D+21+AND+auftrag_revisionnewest+%3D+1+AND+auftrag_id+%3D+45&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&units=esriSRUnit_Foot&outFields=*&returnGeometry=true&outSR=4326&returnDistinctValues=false&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnZ=false&returnM=false&f=geojson";
UserCredentials creds = new UserCredentials();
creds.setSSLRequired(true);
creds.setUserAccount("username", "password");
ArcGISFeatureLayer featureLayer = new ArcGISFeatureLayer(url,(ArcGISFeatureLayer.Options)null,creds);
So the best would be to get just the GeoJSON-String as accessable with the Link. But how can I access the HTTP with the Username and Password?

If you want to do that style of query within the ArcGIS Android SDK you'll have to do it with creating a FeatureLayer and then using the Query class to define the equivalent of your query string. This gives you back a FeatureSet that contains features which should have the information you're looking for, but it won't be in the form of GeoJSON. There's a toJSON method on the FeatureSet that might give you what you're looking for, but I'm not positive. If you just want a pure JSON response, you're going to have to do the HTTP requests yourself, setting up whatever authentication the REST API needs within your request and then handling the response.

Related

Azure App Center Data SDK multiple models issue

I am using App Center's Data SDK with Xamarin Forms. I've got two models Banks & Payment Methods. I am allowing the user to create new objects of both & saving them in App Center's Data using the following methods:
var result = await Data.CreateAsync(newBank.Id.ToString(), newBank, DefaultPartitions.UserDocuments);
var result = await Data.CreateAsync(newMethod.Id.ToString(), newMethod, DefaultPartitions.UserDocuments);
Where newBank is of type Bank & newMethod is of type Payment Method.
When I retrive banks though, I get a list of all documents, including ones for payment methods.
This is how I am retrieving them.
var banks = await Data.ListAsync<Bank>(DefaultPartitions.UserDocuments);
Similarly, while retrieving PaymentMethods, I am getting the bank's objects too.
var methods = await Data.ListAsync<PaymentMethods>(DefaultPartitions.UserDocuments);
Do you spot something wrong I am doing here? I can not see it?
Any help is appreciated in this. Thank you.
Regards
ST
For now, I was able to resolve it using the ClassType property as mentioned in the blog below. https://mikecodes.net/2019/06/18/digging-into-app-center-data/
Let me know if there is a better way to handle this.
Thanks
ST

how to extract parameter value from firebase dynamic link email directly in android activity

I have searched SO a lot but could not find a similar type question. My requirement is simple. I need to get parameter values from Email from my mailbox.My Email look like follows:
https://ejr3J.app.goo.gl/Rerjk?userId=qE721dmnre2dfmd_fdare55EnDB&session=ZwlkEL54_danbreMEdneENfdfm
When i click on this link it opens the desired activity (deep-linked activity) and getting also the deep link url (www.example.com) but cannot retrieve the parameters values (values of userId and session). I've tried to get the value using deeplinkUri.getQueryParameter("userId"), but it returns null value. Please help to accomplish this task. Any help will be appreciated.
I think you wrong in create dynamic link step.
Instead of add parameter to shortlink after it is generated, you must attach parameter in the link url (www.example.com). Like this: www.example.com?userId=qE721dmnre2dfmd_fdare55EnDB&session=ZwlkEL54_danbreMEdneENfdfm; After that, you generate dynamic link.

How to know if an activity is opened from a link in android and fetch the GET parameter from the link?

I have both website and android application for the website.when user clicks on a link of my website it opens that up in my android application. But the problem is there is an important information present in the link which i need to fetch and the activity will make a server request upon that. To be precised the link looks like this: www.example.com/post.php?id=123 I need to get the ID part of the link when the activity is opened so that I can show information about posts bearing the ID. I have added the opening of the link in my app with help of intent filter but I am stuck at getting the GET parameter of the link.How to do that?
Once your activity is opened via the link, you can retrieve that URL from the intent like so:
String url = getIntent().getData().toString();
Then you can use .substring to get the parameters:
String id = url.substring(url.indexOf("id=") + 3)
OR, you can use Airbnb's library to achieve the result in a more elegant way, you can learn about it on their GitHub repo.
myLink = string.substring(string.lastIndexOf('=') + 1);
If the string/url was www.example.com/post.php?id=123 the string will now return 123.

Facebook SDK request api

I have been reading the Facebook documentation. The Facebook documentation for asking/sending gifts mentioned a YOUR_OBJECT_IDfor this call:
FB.ui({method: 'apprequests',
message: 'Take this bomb and blast your way to victory!',
to: 'RECIPIENT_USER_ID'
action_type:'send',`enter code here`
object_id: 'YOUR_OBJECT_ID', // Where do I get this ?
data: 'Friend Smash Custom Tracking 1'
}, function(response) {
console.log(response);
});
How do I get get it? I have already created my object inside Open Graph, but there is no object id specified. Do I need to initiate a create request for the user from my app for that object or how is this suppose to work?
The request_object_id is what you will get back from the dialog, after the user sent the gift – it is part of the dialog’s return value. It is simply the identifier for the request that was send.
https://developers.facebook.com/docs/games/requests/v2.1#response
You can use it to read details of the request back from the API.
OK, so since this is about the object id that one can pass to the dialog:
That documentation section already links to https://developers.facebook.com/docs/sharing/opengraph/custom, where this is explained in more detail.
Basically, you need to set up your own Open Graph action and Open Graph object. This will define what your object is, and what players of the game can do with it.
Open Graph objects can be created in two ways:
You can host them yourself. To do this, you simply provide URLs to HTML pages which include the Open Graph meta data that specifies the object property values. Facebook will then read the meta data from those URLs (“scraping”). In that case, you would simply pass the object URL to the dialog as object_id.
You can use the Object API to create objects that Facebook will host for you. These can either be “app-owned” or “user-owned” – depends on if the are specific to a certain user, or “common” objects to be used by all users of your app. Creating an object via that API will give you back an object id, that you can then pass to the dialog.
If you are not familiar with the whole Open Graph Story concept yet, then I recommend you start by having a look at the whole Open Graph section, https://developers.facebook.com/docs/sharing/opengraph

How to create a object to post score?

I'm developing a game on Android and want to integrate with facebook, so user can share his results.
I'm using the Open Graph to create the actions, the objects and so on from my app.
Already done some progress using direct Graph API requests like this.
Bundle params = new Bundle();
params.putString("my_object", "http://samples.ogp.me/251143638264597" );
mAsyncRunner.request("me/MY_APP_NAMESPACE:beat", params, "POST",
new WallPostRequestListener(), null);
This way the post is made. But ,as you can see on the code above, i'm using the sample object created by Open Graph.
My problem is: how can i create an object dynamically, in java? It's possible? I've already tried to create a JSON object, but didn't have success.
I saw on the tutorials an HTML metadata, but this is the only way to do it?

Categories

Resources