문제

사용자가 특정 URL로 이동할 때 내 의도를 시작하고 싶습니다. 예를 들어 Android Market이이를 수행합니다. http://market.android.com/ URL. YouTube도 마찬가지입니다. 나도 그렇게하기를 원합니다.

도움이 되었습니까?

해결책

나는 그것을했다! 사용 <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.youtube.com" android:scheme="http" />
</intent-filter>

이것은 완벽하게 작동합니다!

다른 팁

다른 경우 (http/ https/ ect)에서 작동하도록 의도 필터에 다른 순열을 추가해야 할 수도 있습니다.

예를 들어, 사용자가 Google 드라이브 양식에 대한 링크를 열 때 열리는 앱에 대해 다음을 수행해야했습니다. www.docs.google.com/forms

경로 접두사는 선택 사항입니다.

        <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="docs.google.com"
                android:pathPrefix="/forms"/>
            <data
                android:scheme="http"
                android:host="www.docs.google.com"
                android:pathPrefix="/forms" />

            <data
                android:scheme="https"
                android:host="www.docs.google.com"
                android:pathPrefix="/forms" />

            <data
                android:scheme="https"
                android:host="docs.google.com"
                android:pathPrefix="/forms" />
        </intent-filter>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top