0

please don't answer by only reading the title of the question..That's not my question..I gave that title only because i couldn't find any other good title for this question...

I've a doubt..Can somebody help me? it's related to opening a specific app from a url. The procedure is explained here

But that's not what I want to know. Is there any way that I can hard code that referral url inside the app?

OR may be this will help u to understand...

imagine, user installed an app from google play by clicking a google play referral link..google play sends the content of referral link as an intent and the broadcast receiver captures it and when the user opens the app for the first time, the referral link will be send back to google analytics for tracking the referral...

BUT

The tracking works only when the user opens the app for the first time after installation...But i want to track it forever..

So what i'm asking is, can i hard code the above said referral link within the app so that whenever the user opens the app manually, the app sends the referral data again(not to google play, but to a server or site that i've already coded in the app?

Please note that i mentioned google play referral only because you can understand my question..

............................................................................

i think this will be more easy to unerstand

case 1: user clicks a url in his browser..browser opens the app...app captures and reports the url

I want the same sequence of things to happen in the following case, except that the user didnt open the app by clicking url, but manually open the app

case 2: user clicks the app's icon in the device..app opens...app reports the url-here is where my question lies-can i hard code the url? (like a browser launched the app)

and the second case should happen every time the user opens the app, manually...that's why i asked if there is a way to hard code the url... ..............................................................................

I think this should explain what I'm looking for

A user opens the app manually (by clicking the app's icon in his device) but the app thinks that the user clicked a specific url (say, www.123.com/abcd-abcd) and that's what opened it.

So any way to achieve this?

Update

I will tell you the use of it.. There may be other better and easy options for achieving this like google play referral tracking or MAT etc..But since this got into my mind, i'm looking for an answer

Imagine, i have an app and i've 3 friends who's willing to share my app...I will create 3 different apk(of the same app) and in the first apk, i will include his website's url(even a fake url will do)..so when the user opens the app manually, it will report to me that it is opened by friend's url and i can identify that he's the sharer..

Then i will give the 2nd apk to my second friend with his url inside and app will report this url to me every time a user opens the app..

Then third apk to 3rd friend with his url and app will report his url to me..

So from looking at the total number of url openings(in fact the user didnt opened the app by clicking any url), i can understand which friend is more effective in sharing my app and if their referrals are engaging with my app regularly or not..

Example: i get a report that app opened by 1st friend's url 50 times..

then i get another report that app opened by 2nd friend's url 100 times

then i get another report that app opened by 3rd friend's url 500 times

So from the above report, i can understand that my third friend is most successful in referring my app or the people he shared the app with are the ones who's engaging with my app mostly...

.............Or think like this:....................

You have an app and you gave your friend a referral link and he shares the link with his friends..His friends clicked the link and the browser opens the app(because the app was already installed in the device)...then your app captures the link and sends it to you..But you want the app to send the link(report) again whenever the same user opens the app manually(by clicking the icon)..so since the user may not click the link again, the app will not send you the link again because it sends only when somebody open the app from a browser..BUT you want the app to report the link every time the old user opens your app(manually)...So any way to hard code the url within the app so that it will report the same way as somebody clicking a link?

And imagine that there is a 2nd friend with a different url and a different apk of the same app(hard coded his url inside the app)

..............................

Community
  • 1
  • 1
Raj
  • 1
  • 4
  • I assume that by running your app via specific URL you mean running some activity of your app which handles URL clicks. If so you can have another acrivity for handling default launch intent and start your URL handling activity from that default activity with the intend data you want. – Eugene Popovich Oct 07 '14 at 11:18
  • 1
    "it should open like you opened it by clicking a url" -- what does this mean, in programming terms? – CommonsWare Oct 07 '14 at 11:18
  • 2
    `String app_thinking = "I opened from an URL. I'm cool"` – Pedro Oliveira Oct 07 '14 at 11:19
  • I mean, the app should think and report that you opened the app by clicking a url in the browser but actually you opened it manually.. – Raj Oct 07 '14 at 11:20
  • When you click on icon the android.intent.action.MAIN intent-filter is triggered. If you click on the link android.intent.action.VIEW is triggered. – Eugene Popovich Oct 07 '14 at 11:25
  • User opens the app manually(clicking the app's icon in the device)-But the app thinks that it is opened by clicking a url, say www.123.com/abc-abcd and informs me that user opened the app by from the browser by clicking www.123.com/abc-abcd. But the user never clicked any link..And every time the user open the app manually, the app should report that user opened it by clicking the url www.123.com/abc-abcd – Raj Oct 07 '14 at 11:26
  • and what will happen when app comes to know that you have opened the app via a URL? – Darpan Oct 07 '14 at 11:27
  • I know that this is confusing...But i've a big comment and that will clear your doubts...But it's more than 600 character...so how to post it? – Raj Oct 07 '14 at 11:28
  • It reports to me that it is opened by a url-the url that's hard coded in the app (but in reality, the user never clicked any url) – Raj Oct 07 '14 at 11:28
  • You need to write new Actiivty which handles android.intent.action.MAIN action. And start your another URL click handling activity from it via the new intent, put the URL you want as a data. – Eugene Popovich Oct 07 '14 at 11:32
  • possible duplicate of http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser – k3b Oct 07 '14 at 11:35
  • What if the app is already set to receive intent from the browser(the intent contains which url triggered the app opening)..can we turn this into achieve what i asked earlier? ie, The browser sends an intent, but the app rejects(or ignore) the intent and sends it's own intent (with my custom url say www.123.com/abcd-abcd) to the activity and the activity reports to me(sends the data to my site or server, whatever) my own custom url. can we do it? – Raj Oct 07 '14 at 11:39
  • k3b, no it's not a duplicate..I'm not looking for how to open an app from a url...I already knows it from the link.. – Raj Oct 07 '14 at 11:41
  • Why can't you create custom intent with your custom URL as you want? – Eugene Popovich Oct 07 '14 at 11:44
  • http://stackoverflow.com/questions/18221663/open-another-app-with-android-intent-action-view – Eugene Popovich Oct 07 '14 at 11:45
  • What if the app is already set to receive intent from the browser(the intent contains which url triggered the app opening)..can we turn this into achieve what i asked earlier? ie, The browser sends an intent, but the app rejects(or ignore) the intent and sends it's own intent or not send an intent but includes(hard coded) the url within the activity which is listening to the intent and the activity reports to me(sends the data to my site or server, whatever) my own custom url. can we do it? – Raj Oct 07 '14 at 11:47
  • It looks like you ar trying to control url for third party app, whcich you can't modify. Is it true? – Eugene Popovich Oct 07 '14 at 11:51
  • i dont understand...what u mean? pls read my main post again...then you may understand what i really meant...I dont know how to explain this more.. – Raj Oct 07 '14 at 11:56
  • And This question is not already answered earlier...i think you guys still don't understand what i really meant.. – Raj Oct 07 '14 at 11:58
  • So you want anticheating system? If so you should be sure you do not have same processing for the activity launched via MAIN intent-filter and via VIEW intent filter. Also you may use same apk for all friends but different referrer parameter inside URL which is handled by APK. – Eugene Popovich Oct 07 '14 at 12:04
  • Still, i dont think u understand.. So think this way..The following is already happening in the app.. the browser sends intent-broadcast receiver recieves it and the activiy related to it gets the data in the intent(here the url ) and sends the url to me.. But now i dont want the intent that the browser sends..I want the activity(the above said activity) to send a hard coded data(url) can we do it?- trigger the activity without receiving any intent then send the hard coded url? – Raj Oct 07 '14 at 12:06
  • Do you have the code sending url to server? If so why can't you replace intent url with the hardcoded url you want? – Eugene Popovich Oct 07 '14 at 12:07
  • that's what i'm asking for..app already have the code to send the data in the intent(ie, the url) to the server..But where and how should i hard code the url? – Raj Oct 07 '14 at 12:11
  • Can you show the code snippet sending the data? – Eugene Popovich Oct 07 '14 at 12:13
  • Not now...i'm not on my pc.. – Raj Oct 07 '14 at 12:14
  • You had to start from that, the question would be much more clear – Eugene Popovich Oct 07 '14 at 12:15
  • I tried to keep the question as simple as possible...but what can i do? :) – Raj Oct 07 '14 at 12:18
  • One last time: don't know how to explain it any more :) let's say you have an app and whenver a user opens the app from a browser, it sends the data(url in which the app got opened) to you..Now you don't want the data from the browser(because from now on nobody will open the app from a url), but want the app to behave like a it is opened from a browser and send you the a link that you already hard coded within the app(so that the app will report you this url every time a user open the app manually), exactly like a url click in the browser that triggered the app opening.. – Raj Oct 07 '14 at 12:24
  • You got it user2450263.. that's exactly what i'm looking for...tracking the app usage with our own method without depending on a third party..and of course, this app will not be on google play but directly given to users...So can you please show the code to me? with this link included in it www.123.com/abcd-efgh-ijkl and can we include the url without using any extra code and by hard coding it to the existing activity which listens to the browser's intent? – Raj Oct 07 '14 at 12:50
  • And let's say i want this reporting to work exactly the same way as the reporting of the url opening from browser. – Raj Oct 07 '14 at 12:58
  • where do you intend to report this? do you have a server, or any setup where you will receive and analyse hits - like your friendA-50times – Pararth Oct 07 '14 at 13:07
  • of course...it's not implemented...that's why i'm asking this here..to find the solution before implementing it... – Raj Oct 07 '14 at 13:08
  • ok guys...leave it if you dont understand what i'm asking...dont know how to explain it any more :) – Raj Oct 07 '14 at 13:44

2 Answers2

0

You can do by using toast

Toast.makeText(MainActivity.this, "http://www.dummyURL.com", Toast.LENGTH_SHORT).show();

this use method inside on create method in MainActivity.java file. If your home file name is not MainActivity then use your file name in place of MainActivity

Kaushik
  • 6,150
  • 5
  • 39
  • 54
LoneRanger
  • 117
  • 8
  • No...i'm not asking how to make a toast in the app...pls see my edited main post again... – Raj Oct 07 '14 at 13:55
0

When you receive link for the first time save it in the SharedPreferences. Next time you open app check whether the url is present in there and send it to server.

Eugene Popovich
  • 3,343
  • 2
  • 30
  • 33