I want to open my app's LoginActivity when click on a <a href="www.myhost.com"/> in some web in Chrome browser app. I have this code but it is not working:
<activity android:label="#string/app_name" android:launchMode="singleTask"
android:name=".activities.LoginActivity" android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:scheme="http" android:host="myhost.com"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
What am I doing wrong?
Thanks.
You need to set it up 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:host="example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
<data
android:host="www.example.com"
android:pathPrefix="/someresource/"
android:scheme="http" />
</intent-filter>
Notice that in your case, you would need to use android:pathPrefix instead of android:path.
Related
I am creating a Browser app and I want Android to treat my app as a browser and show up in the app chooser to open with.
I want my app to show up in this list.
Here is my manifest Activity code:
<activity
android:name=".Activity.LinkDetectorActivity"
android:exported="true"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="testscheme" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Replace your intent-filter with below,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="http"/>
<category android:name="android.intent.category.DEFAULT" />
<!-- The BROWSABLE category is required to get links from web
pages. -->
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Try to change testcheme to "http" and "https"
<activity
android:name=".Activity.LinkDetectorActivity"
android:exported="true"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="http" />
<data android:scheme="https" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
I am working on an android app in that i have added sharing whatsapp sharing feature,I have done it successfully,Now i want to open a specific activity of my android application when user click on link i have shared.I have searched few links but no luck,I hope somebuddy will help me in this.
Added manifest
<activity
android:name=".ProductDescriptionActivity"
android:exported="true"
android:screenOrientation="portrait"
android:theme="#style/Theme.AppCompat.NoActionBar">
<intent-filter>
<action android:name="com.abc.allaboutcity.MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<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="http"
android:host="http://allaboutcity.in"
android:pathPrefix="/allaboutcity" />
</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" />
<!-- Accepts URIs that begin with "example://gizmosā -->
<data android:scheme="allaboutcity"
android:host="allaboutcity" />
</intent-filter>
</activity>
You should add intent filter in your manifest file to activity that you want to open
<activity
android:name="Your Activity"
android:label="Your Activity Title"
android:theme="Your Style">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<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:host="your url"
android:path="/your path"
android:scheme="http" />
</intent-filter>
</activity>
use this code In Your WebView Activity
Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
Webview webView = (WebView) findViewById(R.id.webview_id);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(""+ data);
next, use this code in AndroidManifest.xml, its for all link (Https / Http):
<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="https"/>
<data android:scheme="http"
android:host="http://allaboutcity.in"
android:pathPrefix="/allaboutcity" />
<data android:host="www.host.com" android:pathPattern="/movie/0.*/" android:scheme="http"/>
</intent-filter>
I added a deep linking to my Android app this way:
<activity
android:name=".views.DeepLinkingActivity"
android:exported="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="https"
android:host="example.com"/>
</intent-filter>
</activity>
When I click on https://example.com I get redirected to the web site.
When I change android:scheme="https" to android:scheme="appscheme" it works and it redirects me to my app.
How to force my app to be opened via https scheme?
UPDATE
I added a subdomain and it still doesn't work.
<activity
android:name=".views.DeepLinkActivity"
android:exported="true">
<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="www.example.ru"/>
</intent-filter>
</activity>
Thanks to veritas1 I removed android:autoVerify="true" from https-scheme. I also changed the scheme from https to http. (You can read about autoVerify).
So, currently have two different schemes:
<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="your-site.com"
android:pathPrefix="/"
android:scheme="http"
/>
</intent-filter>
<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:host="your-site.com"
android:pathPrefix="/"
android:scheme="myapp"
/>
</intent-filter>
When clicking on a link myapp://your-site.com/... an application will be opened. When clicking on http://your-site.com/... Chrome browser will offer to open in the application or another browser, while other mobile browsers ignore this and try to open themselves.
UPDATE
See https://stackoverflow.com/a/60342565/2914140 for App Linking.
Hi please use the following data and try also refer this doc
<intent-filter>
<data
android:scheme="ou unique scheme(appname,package name)" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
OR
<data
android:scheme="you unique scheme(appname,package name)"
android:host="www.example.ru"/>
You refer to deep linking but android:autoVerify="true" is used for App linking, so the domain example.com (which you don't own?) is going to get checked for a digital asset links json file. See https://developer.android.com/training/app-links/index.html
For your test to work I'd suggest removing android:autoVerify="true" and adding a subdomain to the host e.g. android:host="www.example.com"
Try this
<activity
android:name=".views.DeepLinkingActivity"
android:exported="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:host="open"
android:scheme="example" />
</intent-filter>
<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:host="example.com"
android:pathPrefix="/"
android:scheme="http" />
</intent-filter>
<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:host="example.com"
android:pathPrefix="/"
android:scheme="https" />
</intent-filter>
</activity>
Please check below it may be help
https://codelabs.developers.google.com/codelabs/android-deep-linking/index.html?index=..%2F..%2Findex#0
Just use http. Don't know when the implementation is changed.
But I just tested that using http will make both http and https work.
So change you intent filter by:
<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="http"
android:host="example.com"/>
</intent-filter>
youe can also add to it
sub.example.com
<intent-filter android:label="#string/app_name">
<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="example.com" />
<data android:scheme="app" android:host="com.example.example" />
</intent-filter>
<activity
android:name=".ActivateActivity"
android:configChanges="orientation"
android:windowSoftInputMode="adjustPan">
<intent-filter >
<data android:host="www.testlink.com.qa" android:pathPrefix="/templates/home.aspx/" android:scheme="http"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
this is my code....its not working when click the link (www.testlink.com.qa) from my email.
but it work when i call from another app using Uri.parse("http://www.testlink.com.qa/templates/home.aspx")
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.testlink.com.qa" android:path="www.testlink.com.qa/templates/home.aspx" android:scheme="http"></data>
</intent-filter>
Email link http://www.testlink.com.qa/templates/home.aspx
I want to run my app from a custom url.
I added the following to the AndroidManifest:
<activity android:name=".app.RunFromUrlActivity"
android:launchMode="singleInstance">
<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="myapp"/>
</intent-filter>
</activity>
However, when i try to go to myapp://data the browser simply searches fot that string instead of running my Activity.
What am i doing wrong?
Try something like this for "data":
<data
android:host="com.yourpackage.yourotherstuff.TheActivity"
android:scheme="yourscheme" />
Here's one that works for my app:
<activity android:name=".BrowserActivity" >
<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="com.mypackage.otherstuff.BrowserActivity"
android:scheme="myapp" />
</intent-filter>
</activity>
This makes my activity accessible via myapp://com.mypackage.otherstuff.BrowserActivity.