WebView😇😇😇

 WebView😇😇😇

Bbe9718bebdafbdc8dabbe3cadf1bc46?s=128

Keishin Yokomaku

November 28, 2017
Tweet

Transcript

  1. 2.

    WebView Keishin Yokomaku 2 potatotips #45 Drivemode, Inc. / Principal

    Engineer @KeithYokoma: GitHub / Twitter / Qiita / Tumblr / Stack Overflow
  2. 7.

    WebView ࠓ೔ͷ WebView ᠘Ϩγϐ ▸ e.g. ๏త৘ใΛ WebView Ͱදࣔ͢Δ ▸

    assets ʹ html Λஔ͍ͯ WebView ʹಡ·ͤΔ ▸ ֎෦ϦϯΫ͕ͳ͚Ε͹࠷΋खܰʹࡁ·ͤΒΕΔ ▸ ಉ͡ assets ಺ͷ html ʹϦϯΫ͢Δ৔߹΋؆୯ ▸ e.g. file:///android_asset/privacy_policy.html 7 potatotips #45
  3. 8.

    WebView StrictMode ▸ ThreadPolicy ͱ VmPolicy ▸ ͋Γ͕ͪͳ࣮૷ͷؒҧ͍Λݕग़ͯ͠ϩάग़ྗ΍ΫϥογϡΛൃੜͤ͞Δ ▸ ϝΠϯεϨουͰ

    I/O ▸ Ϧιʔεͷ close ๨Ε ▸ ΧελϜ͢Δͱ͖͸ඞཁͳ΋ͷ͢΂ͯΛ༗ޮʹ͢Δ ▸ ༗ޮʹͯ͠ͳ͍΋ͷ͸εϧʔ͞ΕΔ 8 potatotips #45
  4. 9.

    WebView Android Nougat ͷηΩϡϦςΟ࢓༷ ▸ FileUriExposureException ▸ File εΩʔϚͷ Uri

    Λ Intent ʹ͍Εͯڞ༗Ͱ͖ͳ͘ͳͬͨ ▸ FileProvider ౳ͷ ContentProvider Ͱڞ༗͢Δ ▸ StrictMode ʹ΋Φϓγϣϯ͕͋Δ ▸ VmPolicy#penaltyDeathOnFileUriExposure() 9 potatotips #45
  5. 10.

    WebView WebView#loadUrl() ͷ࢓༷ ▸ WebViewClient Λࢦఆͨ͠ͱ͖ ▸ shouldOverrideUrlLoading ͕ true:

    ΞϓϦͰಡΈࠐΈΛ؅ཧ ▸ shouldOverrideUrlLoading ͕ false: WebView ͕ಡΈࠐΈΛ؅ཧ ▸ WebViewClient Λࢦఆ͠ͳ͍ͱ͖ ▸ ActivityManager ʹ໰͍߹Θͤͯద੾ͳ΋ͷΛݺͼग़͢ 10 potatotips #45
  6. 11.

    WebView WebView#loadUrl() ͷ࢓༷ ▸ WebViewClient Λࢦఆͨ͠ͱ͖ ▸ shouldOverrideUrlLoading ͕ true:

    ΞϓϦͰಡΈࠐΈΛ؅ཧ ▸ shouldOverrideUrlLoading ͕ false: WebView ͕ಡΈࠐΈΛ؅ཧ ▸ WebViewClient Λࢦఆ͠ͳ͍ͱ͖ ▸ ActivityManager ʹ໰͍߹Θͤͯద੾ͳ΋ͷΛݺͼग़͢ 11 potatotips #45
  7. 13.

    WebView ActivityManager ʹ໰͍߹Θͤͯద੾ͳ΋ͷΛݺͼग़͢ ▸ Intent Λ౤͛ͯϋϯυϧͯ͘͠ΕΔΞϓϦΛ୳͢ ▸ ଘࡏ͢Ε͹ͦͪΒʹ౉͢ ▸ ଘࡏ͠ͳ͚Ε͹

    WebView ͕ϋϯυϧ͢Δ ▸ ͍ͣΕʹͯ͠΋ Intent ʹಡΈࠐΉ Uri ͕٧Ίࠐ·ΕΔ ▸ file:///android_asset/hogehoge.html ͳϦϯΫΛ౿Ήͱ… 13 potatotips #45
  8. 19.

    DroidKaigi DroidKaigi 2018 is coming soon! ▸ Ticket: ▸ Early

    Bird: 9,800 JPY ▸ Regular: 12,000 JPY ▸ Students: 4,000 JPY 19 potatotips #45