When using an intent filter to allow opening certain links from the app 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"/>
<data android:scheme="https"/>
<data android:scheme="custom-scheme"/>
<data android:host="app.dev.example.com"/>
</intent-filter>
The application still proposes to open a link dev.example.com with the app. It is like it is ignoring the starting portion of the host.
Is there a way to only allow app.dev.example.com/... and not dev.example.com/... or example.com/...?
The whole manifest:
<manifest package="com.e.axamplepp"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application android:label="#string/app_name" android:icon="#mipmap/launcher_icon">
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="#style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize">
<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="#style/NormalTheme"/>
<meta-data android:name="flutter_deeplinking_enabled" android:value="true"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</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:scheme="http"/>
<data android:scheme="https"/>
<data android:scheme="custom-scheme"/>
<data android:host="app.dev.example.com"/>
</intent-filter>
</activity>
<meta-data android:name="flutterEmbedding" android:value="2"/>
</application>
<queries>
<intent>
<action android:name="android.intent.action.VIEW"/>
<data android:scheme="https"/>
</intent>
</queries>
</manifest>
make sure your intent filter have action, category
<intent-filter android:label="#string/example">
<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 "http://www.example.com/test” -->
<data android:scheme="http"
android:host="www.example.com"
android:pathPrefix="/test" />
<!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
more details refer Deep linking
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>
When I choosing to upload android Instant App apk-s zip to Google Play Developer Console I receive this error: Upload failed. You must use the http and https protocols for intent filters
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.feature">
<application>
<meta-data
android:name="asset_statements"
android:resource="#string/asset_statements"/>
<activity android:name=".ui.MainActivity">
<tools:validation testUrl="https://com.example/"/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter
android:order="1"
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="com.example"
android:pathPattern="/.*"/>
</intent-filter>
<meta-data
android:name="default-url"
android:value="https://com.example"/>
</activity>
</application>
I was having this problem until I changed my AndroidManifest to this way
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</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" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:pathPattern="/InstantApp" />
</intent-filter>
</activity>
I was using intent-filter to receive dynamic link but also was integrating deep link in navigation graph, for this reason it was also necessary to include "http" and "https" support in the nav_graph.xml document.
<fragment
android:id="#+id/someFragment"
android:name="com.apps.example.SomeFragment"
android:label="fragment_some"
tools:layout="#layout/fragment_some" >
<deepLink
android:id="#+id/deepLink1"
app:uri="https://example.page.link" />
<deepLink
android:id="#+id/deepLink2"
app:uri="http://example.page.link" />
</fragment>
Make sure your intent-filter has at least the following attributes. Both "http" and "https" scheme must be present at the same time:
<intent-filter
android:autoVerify="true"
android:order="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="abc.com" />
<data android:pathPattern="/def" />
<data android:scheme="https" />
<data android:scheme="http" />
</intent-filter>
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.
I need to associate files with particular extension from Google Drive (.gpx, for example) with my app. So when I click the .gpx file on Drive, I should have an option to open this file with my application.
Currently I have an activity handling these files clicking declared in AndroidManifest.XML in a way below, and it works for locally stored files and gmail attachments, but not for Drive:
<activity
android:name=".ui.PhotosActivity"
android:label="#string/app_name"
android:launchMode="singleTop"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:priority="1">
<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"/>
<data android:scheme="https"/>
<data android:scheme="ftp"/>
<data android:scheme="file"/>
<data android:host="*"/>
<data android:mimeType="*/*"/>
<data android:pathPattern=".*\\.gpx"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT"/>
<data
android:mimeType="application/octet-stream"
android:pathPattern=".*\\.gpx"
android:scheme="file"/>
<data
android:mimeType="application/octet-stream"
android:pathPattern=".*\\.gpx"
android:scheme="content"/>
</intent-filter>
</activity>
Add this to your manifest:
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
Then add this to your activity:
<meta-data
android:name="com.google.android.apps.drive.APP_ID"
android:value="id=xxxxxxx" />
where xxxxxxx is your Project ID as declared with Google API console.
<intent-filter>
<action android:name="com.google.android.apps.drive.DRIVE_OPEN" />
<data android:mimeType="application/vnd.google-apps.drive-sdk.1234567890" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.gpx" />
</intent-filter>
I am trying to open a file with my app and to receive a file via the SEND intent.
I've tried several filters in the manifest file but could not get it to be displayed anywhere.
How is this done?
<activity
android:name=".MyActivity"
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>
<action
android:name="android.intent.action.VIEW" />
<category
android:name="android.intent.category.DEFAULT" />
<category
android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="file" />
<data android:mimeType="*" />
<data android:host="*" />
</intent-filter>
</activity>