2 Replies - 1530 Views - Last Post: 25 November 2012 - 04:01 PM

#1 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 93
  • Joined: 22-September 09

How to associate my application with file type

Posted 25 November 2012 - 02:24 PM

I have made an rss reader for the android and i want whenever the mobile browser opens an rss and shows the list of the availiable rss readers that i have to show my application among them.
Is This A Good Question/Topic? 0
  • +

Replies To: How to associate my application with file type

#2 H3R3T1C  Icon User is offline

  • Android Expert
  • member icon

Reputation: 276
  • View blog
  • Posts: 757
  • Joined: 30-March 07

Re: How to associate my application with file type

Posted 25 November 2012 - 02:41 PM

You are going to have to use an intent filter with your activity in AndroidManifest.xml like so:
<activity android:name=".RssActivity">
    
    <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:mimeType="application/rss+xml" />
    
    </intent-filter>

</activity>  



in your activity to get the url that will be passed use this code:
if(this.getIntent().getDataString()!=null)
{
	String path = this.getIntent().getDataString();
}



Also note that some sites may use "text/xml" as the mimeType. In that case just add another intent filter like so:
<activity android:name=".RssActivity">
    
    <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:mimeType="application/rss+xml" />
    
    </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:mimeType="text/xml" />
    
    </intent-filter>

</activity> 


Was This Post Helpful? 1
  • +
  • -

#3 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 93
  • Joined: 22-September 09

Re: How to associate my application with file type

Posted 25 November 2012 - 04:01 PM

thank you very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1