{"id":1821,"date":"2020-04-10T01:23:00","date_gmt":"2020-04-09T16:23:00","guid":{"rendered":"https:\/\/www.itchefblog.com\/?p=1821"},"modified":"2021-04-22T02:58:15","modified_gmt":"2021-04-21T17:58:15","slug":"%ea%b6%8c%ed%95%9c-%ed%99%95%ec%9d%b8-%eb%b0%8f-%ec%9a%94%ec%b2%ad","status":"publish","type":"post","link":"https:\/\/www.itchefblog.com\/?p=1821","title":{"rendered":"\uad8c\ud55c \ud655\uc778 \ubc0f \uc694\uccad"},"content":{"rendered":"<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\/\/Manigest \ud074\ub798\uc2a4\ub294 \uc5ec\ub7ec \ud328\ud0a4\uc9c0\uc5d0 \uc874\uc7ac\ud558\ub294\ub370 android\uc758 \ud328\ud0a4\uc9c0\ub97c \uc784\ud3ec\ud2b8\ud558\uba74 \ub41c\ub2e4.\n\nprivate val REQUEST_READ_EXTERNAL_STORAGE = 1000\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n        setContentView(R.layout.activity_main)\n\n        if(ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){\n\n            \/\/\uad8c\ud55c\uc774 \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc74c\n            if(ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)){\n\n                \/\/\uc774\uc804\uc5d0 \uc774\ubbf8 \uad8c\ud55c\uc774 \uac70\ubd80\ub418\uc5c8\uc744 \ub54c \uc124\uba85\n                alert(&quot;\uc0ac\uc9c4 \uc815\ubcf4\ub97c \uc5bb\uc73c\ub824\uba74 \uc678\ubd80 \uc800\uc7a5\uc18c \uad8c\ud55c\uc774 \ud544\uc218\ub85c \ud544\uc694\ud569\ub2c8\ub2e4.&quot;, &quot;\uad8c\ud55c\uc774 \ud544\uc694\ud55c \uc774\uc720&quot;){\n                    yesButton{\n                        \/\/\uad8c\ud55c \uc694\uccad\n                        ActivityCompat.requestPermissions(this@MainActivity,\n                            arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),\n                            REQUEST_READ_EXTERNAL_STORAGE)\n                    }\n                    noButton {  }\n                }.show()\n                \n            }else{\n\n                ActivityCompat.requestPermissions(this,\n                    arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE),\n                    REQUEST_READ_EXTERNAL_STORAGE)\n\n            }\n\n        }else{\n\n            \/\/\uad8c\ud55c\uc774 \uc774\ubbf8 \ud5c8\uc6a9\ub428\n\t\t\t\t\t\t\/\/\uc2a4\ud1a0\ub9ac\uc9c0\uc5d0 \uc811\uadfc\n\n        }\n\n    }\n<\/pre>\n\n\n<p>\uc0ac\uc6a9\uc790\uac00 \uad8c\ud55c\uc744 \uc694\uccad\ud558\uba74 \uc2dc\uc2a4\ud15c\uc740 onRequestPermissionsResult() \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud558\uace0 \uc0ac\uc6a9\uc790\uc758 \uc751\ub2f5\uc744 \uc804\ub2ec\ud55c\ub2e4. \ub530\ub77c\uc11c \uad8c\ud55c\uc774 \ubd80\uc5ec\ub418\uc5c8\ub294\uc9c0 \ud655\uc778\ud558\ub824\uba74 \uc774 \uba54\uc11c\ub4dc\ub97c \uc624\ubc84\ub77c\uc774\ub4dc \ud574\uc57c\ud55c\ub2e4.<\/p>\n\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\noverride fun onRequestPermissionsResult(requestCode: Int, permissions: Array&lt;out String&gt;, grantResults: IntArray) {\n    super.onRequestPermissionsResult(requestCode, permissions, grantResults)\n    \n    when(requestCode){\n        REQUEST_READ_EXTERNAL_STORAGE -&gt; {\n            if((grantResults.isNotEmpty()) &amp;amp;&amp;amp; grantResults[0] == PackageManager.PERMISSION_GRANTED){\n                \/\/\uad8c\ud55c \ud5c8\uc6a9\ub428\n                getAllPhotos()\n            }else{\n                \/\/\uad8c \uac70\ubd80\n                toast(&quot;\uc811\uadfc \uad8c\ud55c\uc744 \uac70\ubd80\ud558\uc168\uc2b5\ub2c8\ub2e4.&quot;)\n            }\n            return\n        }\n    }\n}\n<\/pre>\n\n\n<p>\uc704\uc758 \uc608\uc81c\ub294 \ud558\ub098\uc758 \uad8c\ud55c\ub9cc \uc694\uccad\ud558\uc600\uc73c\ubbc0\ub85c grantResults\uc758 [0]\ubc88\uc9f8 \uc778\ub371\uc2a4 \uac12\ub9cc \ud655\uc778\ud55c\ub2e4.<br>\uc5ec\ub7ec \uad8c\ud55c\uc744 \uc694\uccad\uc2dc \ud574\ub2f9 \uac2f\uc218\ub9cc\ud07c\uc758 \uc778\ub371\uc2a4\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc73c\uba70, \uad8c\ud55c\uc774 \uc2b9\uc778\ub418\uba74 PERMISSION_GRANTED\ub97c<br>\uac70\ubd80\ub418\uba74 PERMISSION_DENIED\ub97c \ubc18\ud658\ud55c\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc0ac\uc6a9\uc790\uac00 \uad8c\ud55c\uc744 \uc694\uccad\ud558\uba74 \uc2dc\uc2a4\ud15c\uc740 onRequestPermissionsResult() \uba54\uc11c\ub4dc\ub97c \ud638\ucd9c\ud558\uace0 \uc0ac\uc6a9\uc790\uc758 \uc751\ub2f5\uc744 \uc804\ub2ec\ud55c\ub2e4. \ub530\ub77c\uc11c \uad8c\ud55c\uc774 \ubd80\uc5ec\ub418\uc5c8\ub294\uc9c0 \ud655\uc778\ud558\ub824\uba74 \uc774 \uba54\uc11c\ub4dc\ub97c \uc624\ubc84\ub77c\uc774\ub4dc \ud574\uc57c\ud55c\ub2e4. \uc704\uc758 \uc608\uc81c\ub294 \ud558\ub098\uc758 \uad8c\ud55c\ub9cc \uc694\uccad\ud558\uc600\uc73c\ubbc0\ub85c grantResults\uc758 [0]\ubc88\uc9f8 \uc778\ub371\uc2a4 \uac12\ub9cc \ud655\uc778\ud55c\ub2e4.\uc5ec\ub7ec \uad8c\ud55c\uc744 \uc694\uccad\uc2dc \ud574\ub2f9 \uac2f\uc218\ub9cc\ud07c\uc758 \uc778\ub371\uc2a4\ub97c \ud655\uc778\ud560 \uc218 \uc788\uc73c\uba70, \uad8c\ud55c\uc774 \uc2b9\uc778\ub418\uba74 PERMISSION_GRANTED\ub97c\uac70\ubd80\ub418\uba74 PERMISSION_DENIED\ub97c \ubc18\ud658\ud55c\ub2e4.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[349,372,7,4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1821"}],"collection":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1821"}],"version-history":[{"count":1,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1821\/revisions"}],"predecessor-version":[{"id":1822,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/1821\/revisions\/1822"}],"wp:attachment":[{"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1821"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1821"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itchefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1821"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}