I have two applications, AppOne and AppTwo.
AppOne is a simple app which exports an Activity so that it can be launched from a webpage with following Intent-Filter
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="what should be the host for a local page?"
android:scheme="what should be the scheme?" />
</intent-filter>
AppTwo contains an activity which has a WebView. In WebView, I am loading a local html page, index.html with following href
launch app
Specifically, I want to know
What should be the host name for a page loaded locally?
What should be the scheme as per the scenario?
Thanks
The scheme can be anything you want it to be - so choose a word that means something to your app such as "apptwo".
If your scheme is unique, then you don't need to specify the host in the data part of the intent filter. If you are simply using the link as a trigger (ie. you always load the same page index.htm), then it doesn't matter what the rest of the URL is.
In AppTwo, you then simply have to arrange to load the relevant file into the webview when the intent fires.
<a href="apptwo://trigger">launch app</a>
Related
In my app, I need to open one page from out side app, through link which is in email.
In my app when some one will create post from our website then we are sending email with url.
When user will click on url/link then it will open respective page in the app.
I need to pass some id and other value to the activity when it launch.
Example:
we are sending following link through email when some one create post on website.
https://www.example.com/lt-url-redirector.php?user_guid=4074395¬ify_entity_id=7221752¬ification_type=22¬ify_id=56933b6219b05172&baseurl=https://www.example.com/groups/calendar/aggregation/mlt
After clicking on above link it goes to mobile browser where "Open in App" button is there.
After taping on this button it gives:
window.location.href = 'abcdef:/?user_guid=4074395¬ify_entity_id=7221752¬ification_type=22¬ify_id=56933b6219b05172&baseurl=https://www.example.com/groups/calendar/aggregation/mlt';
I want to pass notify_entity_id, notification_type, notify_id etc to the activity when it launch.
Android Manifest code :
<intent-filter>
<data android:scheme="abcdef" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Those are query parameters, and there are a variety of methods on Uri for retrieving those values, such as getQueryParameters(). To get the Uri, call getIntent().getData() from some likely spot, such as onCreate() of your activity.
I am trying to implement a new feature for my android application.
scenario :
when some event occurs, the camera sends an email to my (Gmail) account.
on opening the mail, it will have a link (html).
when user clicks on that link, it should launch my application Home activity.
I need to understand :
how to create that html link.
how can i make the link to launch my application Home activity.
kindly help me to understand what all things i need to do in my application.
I used "Blackbelt's" user comment and i was able to get the intent html link working.
But my problem is : i want to use a custom scheme "mobile" instead of "http"
I am using Gmail to use the link. But when i send using custom scheme. Gmail doesnt recogonise as hyperlink. So i cannot click on the link.
Please help me how to use a custom scheme. with gmail
you need to register an intent-filter for your Activity on the AndroidManifest.xml file, defining a custom url. . E.g.
<activity android:name="path.to.YourActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https"
android:host="it.is.my.app" />
</intent-filter>
</activity>
So if you press on a link like https://it.is.my.app, you should be prompted with the android intent chooser, with your app
I had a problem with Custom URI.
Custom URI : scheme:\music\album\tamil\albumID
When I mail this as text it appears as link in iOS devices as link but not in Android devices.
When user select/click the Cutom URI it should navigate to my app and have to show the appropriate content.
This custom URI is passed from one website's button click. In iOS device its react as link not in Android devices.
The web end passing the Custom URI as below
href="scheme://music/tamil/album/albumID"
As a Android developer what should I do to resolve this ?.
Or from web end how to pass the Custom URI as link?.
I think your mail provider/client is responsible for this behaviour. Gmail for example removes custom URIs and replaces href links from <a> tags. This may be for security reasons, not sure why. I suggest you to use "http" as scheme. Then Android will prompt you to open with browser or your app. Add intent filter as below example.
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
You may also add a android:host, and android:path or android:pathPrefix if needed.
Another option is to use a redirect 302. An example for php is below. The drawback is this will open the browser at first.
<a href="openmyapp.php?cat=music&albumID=9128">
<?php
header("Location: scheme://". $_SERVER['QUERY_STRING']);
exit;
?>
I want to create an activity that opens only when links with a specific URL are clicked.
For example: i want to open http://mysite.xyz/test?param=val#myid=12345 with my app (activity), but http://mysite.xyz/test?other=stuff i want to be opened with default browser.
I'm trying to create an intent filter like this:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http"
android:host="mysite.xyz"
android:pathPattern="????" />
...
</intent-filter>
My problem is that android:pathPattern or pathPrefix do not (seam to) verify the query string (any text after the ? or the last /).
Is there a solution for this filtering ?
I haven't tried it myself, but I think you can handle the links based on the URL path, up to the "?" or the last "/". Then, in your activity, check the last part (after ? or last /) and if it doesn't match your criteria, you can redirect the user back to the default browser.
You can use android:ssp, android:sspPrefix and android:sspPattern attributes.
But it works only in 4.4 and higher.
My WebView application loads a html file and display it. Now how do I register it as a default HTML Reader in the Android system?
Meaning for example now if I click on an html attachment in email it shows "Complete Action using", then lists the HTML Readers in the Android system. How do I register my application to be one of them listed?
Must I modify my code to allow this? Currently my application is just loading a html attachment from the sdcard.
Thanks In Advance,
Perumal
This will do the trick:
<activity android:name=".YourBrowserActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
</intent-filter>
</activity>
Replace YourBrowserActivity with the name of your activity class. Call getData() on getIntent() to receive the URL or the requested page.
This will not replace the browser, however. If you tap on the earth symbol on the bottom of the home screen, this will not open your browser.