Android - create a schema for my app that will open from a webpage link -


i'm trying create schema myapp://somthing/anotherthing if webpage or other app link schema open app.

i've added androidmanifest.xml main activity:

    <activity         android:name="com.example.mainactivity"         android:label="@string/title_activity_main"         android:configchanges="orientation"         android:screenorientation="portrait"         android:theme="@android:style/theme.light.notitlebar" >         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />             <category android:name="android.intent.category.default" />             <data android:scheme="myapp" />         </intent-filter>     </activity> 

but when click link in webpage that's linking myapp://somthing/anotherthing gives me page not found type of error , not open app.

everywhere look, see need add <data> tag inside <intent-filter>. missing here?

searching examples in other related questions couldn't find 1 using both <action android:name="android.intent.action.main" /> , <action android:name="android.intent.action.view" /> (the latter seems mandatory kind of behaviour).

anyway, possible use both. working example:

<activity         android:name="com.example.mainactivity"         android:label="@string/title_activity_main"         android:configchanges="orientation"         android:screenorientation="portrait"         android:theme="@android:style/theme.light.notitlebar" android:exported="true">             <intent-filter>                 <action android:name="android.intent.action.main" />                 <action android:name="android.intent.action.view" />                  <category android:name="android.intent.category.launcher" />                 <category android:name="android.intent.category.default" />                 <category android:name="android.intent.category.browsable" />                  <data android:scheme="myapp" />             </intent-filter>         </activity> 

so, following tags seem trick:

android:exported="true" <action android:name="android.intent.action.view" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.browsable" /> 

this anchor i'm using web page:

<a href="myapp://somthing/anotherthing">open app!</a> 

update: developer82 mentioned in comments, if app icon dissapear , user won't able open app. fix this, you'll need create new tag put <data> along default, browsable categories , view action.

the <activity> tag should this:

    <activity             android:name="com.example.mainactivity"             android:label="@string/title_activity_main"             android:configchanges="orientation"             android:screenorientation="portrait"             android:theme="@android:style/theme.light.notitlebar" android:exported="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="myapp" />             </intent-filter>             </activity> 

let me know if helped!


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -