我試圖打開從Chrome中我的應用程序,但它不爲我工作..Android的意圖與鉻:「沒有找到」
下面是官方(非常有限)文檔: Android Intents with Chrome
我發現了一堆類似的問題,但沒有一個解決方案似乎適用於我 - 還有,答案有點零碎,所以我正在尋找完整的答案。我很樂意張貼我的完整的解決方案,只要我們發現它:)
- Launching an Android Application from the Browser
- Open Android app from URL using intent-filter not working
這是我現在得到:
的AndroidManifest.xml:
<activity android:name=".ActMain" >
<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="http" />
<data android:scheme="https" />
<data android:scheme="sharedr" />
<data android:host="pocketr.rejh.nl" />
<data android:pathPattern="/.*" />
</intent-filter>
</activity>
Javascript(它建立用戶的意圖鏈接點擊一個元素上):
var url = "http://icerrr.rejh.nl/"
var title = "Example"
var intenturl = "intent://sharedr/#Intent;"
+ "package=com.rejh.sharedr;"
+ "S.action=share;"
+ "S.type=url;"
+ "S.title="+ app.helpers.encodeURIComponent(title) +";"
+ "S.url="+ app.helpers.encodeURIComponent(url) +";"
+ "end";
alert(intenturl); // for debugging
try {
window.location.href=intenturl;
} catch(e) { alert(JSON.stringify(e)); }
我得到這個功能,下面的 '鏈接':
intent://sharedr/#Intent;package=com.rejh.sharedr;S.action=share;S.type=url;S.title=Example;S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;end
人類可讀:
intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
所以此工程在:它打開Play商店並顯示「找不到物品」和一個刷新按鈕。因此,它打開了一個活動,但不正確的..
網站我想這火是從http://pocketr.rejh.nl
幫助?
完整的答案
正如指出的馬蒂亞下面(我只是想通了這一點,但我自己找到了答案等着我...:P)
首先:我忘了以包括 '計劃= sharedr' 在我的意圖鏈接:
intent://sharedr/#Intent;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
應爲(注意2號線):
intent://sharedr/#Intent;
scheme=sharedr;
package=com.rejh.sharedr;
S.action=share;
S.type=url;
S.title=Example;
S.url=http%3A%2F%2Ficerrr.rejh.nl%2F;
end
然後,在Android清單:
<activity android:name=".ActMain" >
<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="sharedr" android:host="sharedr" android:path="/"/>
</intent-filter>
</activity>
在哪裏機器人:方案= 「sharedr」'是 '方案= sharedr' 部分和 '機器人:主機= 「sharedr」' 對應於「意圖: // sharedr /'
謝謝!
哦,我的上帝,我只是想通了這一點我:P爲什麼-O-爲什麼不DOC有「鏈接」和相應的androidmanifest的示例:P我將在一秒內用完整的解決方案更新我的問題。謝謝! – REJH