Tuesday 12 February 2013

Use an intent filter to open app from weblink



      This is a simple piece of code that helps user to open an application installed in the device by matching the web app website link that is entered to the browser.

      To elaborate the usability.  Once the I enter the link into the browser he is pop upped with an alternate option to open the app installed in device or to navigate tot the application website link



Code is here :



1:        <intent-filter>  
2:          <category android:name="android.intent.category.DEFAULT" />  
3:          <category android:name="android.intent.category.BROWSABLE" />  
4:          <data android:host="trkalimuthu.com" android:scheme="http" />  
5:          <data android:host="www.trkalimuthu.com" android:scheme="https" />  
6:          <action android:name="android.intent.action.VIEW" />  
7:        </intent-filter>  





next pice of code is used webapp to lunch android app.


add this code in android mainfest file :
1:  <intent-filter>  
2:      <action android:name="com.trkalimuthu.android.MY_ACTION" />  
3:      <category android:name="android.intent.category.DEFAULT" />  
4:      <category android:name="android.intent.category.BROWSABLE" />  
5:  </intent-filter>  


following code will apper in webapp :

1:   <a href="intent:#Intent;action=com.trkalimuthu.android.MY_ACTION;end">Lunch App</a>  





the following code is used for lancu the webapp via application 

1:   startActivity(new Intent(Intent.ACTION_VIEW,  
2:                 Uri.parse("http://commonsware.com/sample")));  







No comments:

Post a Comment