my app launches on clicking a link.
But there is additional information that the link contains which my app wants.
The link is something like this :
http://update_app_config.com?parameter1='value1'¶meter2='value2'¶meter3='value3'
can I get an object of key,value pair which contains the parameter and values or do I have to parse it myself?
Thanks
getIntent().getUri() will return a Uri object representing the link used to launch your app. You can then call methods like getQueryParameterNames() and getQueryParameters() to access the query parameters (stuff to the right of the ?).
Related
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.
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.
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
I referred https://developers.facebook.com/docs/opengraph/location_tagging/
While trying to publish checkin, I passed place as place=(some url like "http://www.example.com/jeffys_burgers.html") along with lat,long coordinates and facebook user_id from android app,it
responds {"error":{"message":"(#100) Requires a valid Place Page ID","type":"OAuthException","code":100}}.
My query is how to specify actions,object type in my facebook app so that I can pass appropriate arguments from android app, for publishing checkin at a custom place ?
In the documentation you link to (in the section "Specifying Object Type") they create an object type called "Venue" of the type "Place". You have to do something similar. You don't have to call it "Venue" though.
Remeber that the object type Place is a "Facebook Place". Your jeffys_burgers.html should have og:type=yournamespace:venue (if you decide to call your object type "Venue"), and have the place:location:latitude and place:location:longitude set.
Looking at content providers, I'm not quite clean on the typical usage of the getType() method. The API doc says about implementing this method that
This allows [applications] to retrieve the MIME
type for a URI when dispatching
intents.
Could anyone describe a typical case where using it would be particularly useful?
For example, you're writing content provider for picture gallery. You should mention in your getType() method that you provide pictures - jpg or png. So, when one will launch image gallery, it will be able to show built-in pictures and pictures provided by your content provider.
In pseudocode the user of contentProvider do something like:
List contentProviders = getProviders();
List resultProviders;
final Type type = Type.JPG;
for (ContentProvider provider : contentProviders) {
if (type == provider.getType()) {
resultProviders.add(provider);
}
}
This is pseudocode, but I hope you will got the idea.
As I understand it, a use case could be the following:
App A contains the content provider. App B uses that content provider to retrieve all the data items from App A. The user then picks one of these (in App B) and after that an activity in App A to show/edit/delete the selected data item should be started. So App B then creates an intent, and to make sure that an activity in App A handles it, you need to set the (mime-)type of the intent to the mime-type of the uri (the show/edit/delete activities in App A has added this mime type to their intent filters).