2016-12-17 45 views
2

如果有人點擊一個鏈接,它表示'打開',您可以選擇'Firefox,Chrome ...' 如何將我的應用程序放在那裏如果有人點擊我的應用程序名稱...我的應用程序開始使用包含此鏈接的參數。我希望我的應用處於「打開」瀏覽器部分

對不起,如果這是錯誤的部分。

+0

不知道,但可以幫助你 請參閱此處[打開](http://stackoverflow.com/questions/11152838/why-isnt-my-app-on-the-list-of-apps-to-open -txt-file) –

+0

你聽說過intentFilter嗎?做一個小小的搜索和短語你的問題, – Elltz

回答

1

使用<intent-filter>

說明: 指定類型的活動,服務或廣播接收器能夠響應意圖的。一個intent過濾器聲明瞭它的父組件的能力 - 一個活動或服務可以做什麼以及接收器可以處理什麼類型的廣播。它打開組件以接收廣告類型的意圖,同時過濾掉那些對組件無意義的內容。 過濾器的大部分內容由其<action>,<category><data>子元素描述。

下面是一個例子

<a href="http://stg.bbc.in/press-rel/abc.html">click me!</a> 

AndroidManifest.xml看起來是這樣的:

<activity 
    android:name=".DashBoard" 
    android:label="@string/title_activity_dash_board" 
    android:exported="true" 
    android:theme="@style/AppTheme.NoActionBar"> 
    <intent-filter> 
     <data 
      android:host="www.bbc.in" 
      android:pathPrefix="/" 
      android:scheme="https" /> 
     <data 
      android:host="www.stg.bbc.in" 
      android:pathPrefix="/" 
      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> 

注意:意圖標誌的訂單可能會導致問題,像這樣使用上述

「我建議你簡單地使用該標籤中的新子元素製作另一個<intent-filter>,以避免「看here

+0

'href =「market://'???這個鏈接不會被一個http scheme意圖過濾器捕獲,我想。 – greenapps

+0

將啓動Android Market,谷歌播放搜索欄真正的鏈接將是https://play.google.com/store/search?q=market%3A%2F%2Fsearch%3Fq%3Dpname%3Acom.nytimes.android&c=apps&hl=en,同樣的事情你可以找到你是否輸入market:// search?q = pname:com.nytimes.android在google上播放搜索:P –

+0

可以,但是OP希望他的應用程序在http:// href中位於列表中。 – greenapps

1

您需要將以下<intent-filter>添加到清單文件中的Activity(它將在您的應用中打開)定義中。

<action android:name="android.intent.action.VIEW" /> 
<category android:name="android.intent.category.BROWSABLE" /> 

<category android:name="android.intent.category.DEFAULT" />是可選的,並且僅用於消耗默認意圖。

+0

也謝謝,我現在可以提交url作爲我的應用程序的參數?我的應用用這個URL做了一些事情。提前致謝 ! –

+0

當您的活動開始時,您將獲得意圖數據中啓動此意向的URL。 – Swayam

+0

如果您想讓我詳細說明,請告訴我,如果您仍然無法找出解決方案。 – Swayam

相關問題