Custom URI in Android devices and iOS devices - android

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;
?>

Related

How can I make deep links clickable on Google Calendar

I am trying to save a deep link in my calendar and make it clickable.
My URI has a format like
appname://timer?2000sec&ringtone?jinglebells.
On iOS, in the Calendar, I see it properly. It shows the text in red and if I click it, it opens the app. This, btw, is under "notes", not in the URL field.
On Android however this does not seem to be working properly, the Deep Link is not recognized. It works in other places! I know if the info.plist has a wrong name for the scheme it won't recognize, but I created an HTML page with the appname:// as hyperlink, and if I open it in chrome and click it, it does exactly what it is supposed to, so the AndroidManifest.xml should be set up correctly. But unless I specifically mark it as a Link (be it hyperlink or anything else) it is seen by Android as plane text.
Now, is there a way to force Android to see it as something clickable in the notes field in the Calendar?
Side info:
<!-- Deep linking, this is under the mainActivity <activity> tag -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="rheinbahnnextgen" />
I am using flutter for this, the package I am using is https://pub.dev/packages/add_2_calendar
As I just found out, Google Calendar supports hyperlinks
link

invoking an intent using html link

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

Launching an android application from a web page

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&lt/a>

In Android, how to open an app in browser

Suppose I have a web page, and I load that page in a browser on an android device. What I expect is, when I click a button in the web page, an app can be opened.
Is there any way to do that? Thanks a lot.
you can achieve this using <intent-filter> with a <data>.
For example, to handle all links to sample.com, you'd put this inside your in your AndroidManifest.xml:
<intent-filter>
<data android:scheme="http" android:host="sample.com"/>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
this one was well explained by Felix in his answer here
hopes this helps you...
If you have the option to customize the app in question, you could add an Intent Filter for a specific URI scheme which is unique to your app. Then in the click event for the button of the web page, use this URI scheme to launch your app.
For example, Google Play uses a market:// scheme to open the Google Play app from links.
using IntentFilters it is possible..
Chack out the following code:-
<intent-filter>
<data android:scheme="**myapp**" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" /> <--Not positive if this one is needed
...
</intent-filter>
now you can start your app like myapp://
you can use getIntent().getData() which returns a Uri object. You can then use Uri.* methods to extract the data you need. For example, let's say the user clicked on a link to http://twitter.com/status/1234:
Uri data = getIntent().getData();
String scheme = data.getScheme(); // "http"
String host = data.getHost(); // "twitter.com"
List<String> params = data.getPathSegments();
String first = params.get(0); // "status"
String second = params.get(1); // "1234"
You can do the above anywhere in your Activity, but you're probably going to want to do it in onCreate(). You can also use params.size() to get the number of path segments in the Uri. Look to javadoc or the android developer website for other Uri methods you can use to extract specific parts.

Android custom URI scheme incorrectly encoded when type in browser

I am writing my android application, which I want to define a custom URI scheme, so that user can go to my app by typing a URI in browser, like: myapps://cate=1&id=3
I successfully implemented this in my apps, but I discover that for some device, the browser treat the link differently.
In my HTC Flyer, it opens my app correctly, but in Samsung Galaxy Ace, the browser translates the link to myapps%3A%2F%2Fcate=1%26id=3, which is encoded, and it just google the "myapps://cate=1&id=3" for me instead of open the app.
I define the intent filter in the manifest like this:
<intent-filter >
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="myapps"/>
</intent-filter>
Any help on this issue? thanks
EDITED
I just looked at the source code of android browser, it defined what scheme it accepts:
protected static final Pattern ACCEPTED_URI_SCHEMA = Pattern.compile(
"(?i)" + // switch on case insensitive matching
"(" + // begin group for schema
"(?:http|https|file):\\/\\/" +
"|(?:inline|data|about|content|javascript):" +
")" +
"(.*)" );
Now I understand why custom scheme won't work!
Any apps should only capture schemes: http,https,file,inline,data,about,content,javascript.
Why does it have to be a custom uri?
I'd try it with a standard URL and then I'd define a broadcast receiver for it.
That's essentially how http://youtube.com or http://maps.google.com work I think. Just try typing those two URLs in your Android browser of your Galaxy Ace.

Categories

Resources