{"action":"created","issue":{"url":"https://api.github.com/repos/android-cn/android-discuss/issues/174","labels_url":"https://api.github.com/repos/android-cn/android-discuss/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/android-cn/android-discuss/issues/174/comments","events_url":"https://api.github.com/repos/android-cn/android-discuss/issues/174/events","html_url":"https://github.com/android-cn/android-discuss/issues/174","id":78805820,"number":174,"title":"如何检测程序是否获得了某项权限？","user":{"login":"start141","id":6055764,"avatar_url":"https://avatars.githubusercontent.com/u/6055764?v=3","gravatar_id":"","url":"https://api.github.com/users/start141","html_url":"https://github.com/start141","followers_url":"https://api.github.com/users/start141/followers","following_url":"https://api.github.com/users/start141/following{/other_user}","gists_url":"https://api.github.com/users/start141/gists{/gist_id}","starred_url":"https://api.github.com/users/start141/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/start141/subscriptions","organizations_url":"https://api.github.com/users/start141/orgs","repos_url":"https://api.github.com/users/start141/repos","events_url":"https://api.github.com/users/start141/events{/privacy}","received_events_url":"https://api.github.com/users/start141/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-05-21T03:27:39Z","updated_at":"2015-08-24T05:59:32Z","closed_at":null,"body":"众所周知，MIUI、Flyme等Android定制系统在程序请求打开相机、录音等操作时，系统会先弹出对话框提示用户是否允许程序执行这些操作，如果用户选择允许，则接下来的操作一切正常，如果用户选择拒绝之后，程序后面的工作将无法正常允许，甚至崩溃。\r\n\r\n提问：在这种情况下，如何判断用户是拒绝还是允许了操作？\r\n目前我知道用try catch可以粗暴的判断，但我不确定所有的权限请求被拒绝后都会抛异常。\r\n\r\n各位有更好的办法吗？"},"comment":{"url":"https://api.github.com/repos/android-cn/android-discuss/issues/comments/134049891","html_url":"https://github.com/android-cn/android-discuss/issues/174#issuecomment-134049891","issue_url":"https://api.github.com/repos/android-cn/android-discuss/issues/174","id":134049891,"user":{"login":"start141","id":6055764,"avatar_url":"https://avatars.githubusercontent.com/u/6055764?v=3","gravatar_id":"","url":"https://api.github.com/users/start141","html_url":"https://github.com/start141","followers_url":"https://api.github.com/users/start141/followers","following_url":"https://api.github.com/users/start141/following{/other_user}","gists_url":"https://api.github.com/users/start141/gists{/gist_id}","starred_url":"https://api.github.com/users/start141/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/start141/subscriptions","organizations_url":"https://api.github.com/users/start141/orgs","repos_url":"https://api.github.com/users/start141/repos","events_url":"https://api.github.com/users/start141/events{/privacy}","received_events_url":"https://api.github.com/users/start141/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T05:59:32Z","updated_at":"2015-08-24T05:59:32Z","body":"这个问题可能是因为你在多个地方release()了，你可以在release()之后设置camera=null，下次release()的时候先判断camera是不是等于null。\r\n还有可能是你try catch之后没有return后面的操作。\r\n\r\n总之你看一次Log的错误行数吧，跟一下流程。@Qixingchen 已经说了原因。"}}