0
採取uri數據嗨,我必須做android應用程序和瀏覽器之間的連接。所以,當點擊瀏覽器上的按鈕時,它應該重定向到android應用程序。在Android的活動我已經寫通過意圖在android
Uri data = getIntent().getData();
if (data.equals(null)) {
System.out.println("Data is null");
} else {
String scheme = data.getScheme();
System.out.println(scheme);
String host = data.getHost();
int port = data.getPort();
List<String> params = data.getPathSegments();
String first = params.get(0); // "hello"
System.out.println(first);
和表現我已經在按鈕的HTML已經給
<intent-filter>
<data android:scheme="Integration" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
點擊<FORM METHOD="LINK" ACTION="Integration://1">
它扔indexoutofboundexception我已經給了。 請告訴我哪裏是錯誤
更新 *我是不必要的使用意圖在活動。通過在html5中刪除n參數,我的應用程序現在可以運行成功。 *
我更新的代碼。它給予索引超出限制的例外。我沒有y – Naina
'params.get(0)'沒有參數意味着你不能得到第一個參數,因此'inderOutOfBounds' –
好的。但在HTML ACTION =「Integration:// h \t」>我傳遞參數「h」並在活動代碼中,我正在採取String first = params.get(0);.如果它不起作用,那麼我可以單獨編寫ACTION =「Integration://」> – Naina