2013-02-19 119 views
9

嗨,大家好,我一直在嘗試從電子郵件鏈接或某些社交網站上發佈的應用程序啓動應用程序。我知道這個問題已經被一些朋友提出,但仍然面臨的問題是,在某些設備或Android上的某些gmail應用程序不顯示我指定的錨點標記或鏈接。從鏈接或電子郵件啓動Android應用程序

的意圖過濾器,我設置爲我的行爲是下面:

<action android:name="android.intent.action.VIEW" /> 
<category android:name="android.intent.category.DEFAULT" /> 
<category android:name="android.intent.category.BROWSABLE" /> 
<data android:scheme="myappname" /> 

,我持這種定位標籤發送電子郵件

myappname://processtobedone/?id=1 

它工作正常的電子郵件應用程序,我在Huewai設備上,但在設備的默認gmail應用程序中,它沒有顯示它有鏈接,並且在某些設備中,默認情況下會附加https:作爲標籤的後綴並啓動瀏覽器。

希望你能理解我的問題,希望能有更好的迴應。

感謝提前。

+0

[在Android瀏覽器中創建鏈接啓動我的應用程序?]的可能重複(http://stackoverflow.com/questions/3469908/make-a-link-in-the-android-browser-啓動我的應用程序) – 2017-02-27 01:00:13

回答

2

建立一個真正的鏈接(http :),讓你控制的網站,如亞馬遜s3上的靜態網站,使用該網站上的javascript來檢測android用戶代理,然後重定向到帶有錨標籤的鏈接。

+0

你甚至不需要JavaScript。如果''具有網頁URL而不是自定義方案,則用戶可以選擇直接打開該應用程序。 – CommonsWare 2013-02-19 14:49:51

+0

@CommonsWare啊,多數民衆贊成在Instagram必須工作。我總是想知道這是如何選擇 – CQM 2013-02-19 15:01:34

+0

@CommonsWare你可以請告訴如何定義url而不是定製方案。 – CodingRat 2014-07-22 10:59:49

12

而不是使用自定義的方案,你可以有一個<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:host="www.this-so-does-not-exist.com" 
     android:path="/something" 
     android:scheme="http"/> 
</intent-filter> 

然後鏈接到http://www.this-so-does-not-exist.com/something將帶給你的應用程序(在選擇器,與Web一起瀏覽)具有您的應用的設備上,並且會在沒有您的應用的設備上顯示您的網頁。

+0

謝謝並抱歉延遲迴復@CommonsWare。我會試試這個。 – Dinash 2013-02-20 07:17:43

+0

嗨謝謝你的回答,並且它在大多數設備上都能正常工作,但並不是因爲它與HTC EVO 4G不兼容。每當我點擊鏈接時,它都會直接打開瀏覽器,我確信它是如此。還檢查是否設置了任何默認值並且未設置。 – Dinash 2013-02-26 06:12:10

+0

@Dinash:這種方法可能無法在美國出貨的各種HTC設備上使用,原因在於由蘋果公司獲得的導入禁令產生的解決方法。請參閱http://commonsware.com/blog/2012/07/23/linkify-problem-patent-behavior.html和http://commonsware.com/blog/2012/07/24/linkify-problem-detection-mitigation html的 – CommonsWare 2013-02-26 12:52:36

0
<activity 
android:name=".SplashEmailActivity" 
android:screenOrientation="portrait" 
android:exported="true" 
android:launchMode="singleInstance" android:configChanges="orientation|keyboard|keyboardHidden|screenSize" 
android:windowSoftInputMode="stateHidden|adjustResize" > 

<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" android:host="your.domain.name"/> 

</intent-filter> 

</activity> 
相關問題