Android 6.0 Marshmallow パーミッション対応リファレンス集


# はじめに
自分用にまとめた公式ドキュメントを中心としたリファレンス集です。

どこから入ればいいの？という方は、日本語ブログをさらっと読んで、トレーニングに進むのがよいと思います。

# 公式ドキュメント

### Android 6.0 Marshmallow ポータル  
http://developer.android.com/intl/ja/about/versions/marshmallow/index.html

### System Permissions  
http://developer.android.com/intl/ja/guide/topics/security/permissions.html

### Normal and Dangerous Permissions  
http://developer.android.com/intl/ja/guide/topics/security/permissions.html#normal-dangerous


Dangerous permissions and permission groups.

<table>
  <tbody><tr>
    <th scope="col">Permission Group</th>
    <th scope="col">Permissions</th>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#CALENDAR">CALENDAR</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#READ_CALENDAR">READ_CALENDAR</a></code>
        </li>
      </ul>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#WRITE_CALENDAR">WRITE_CALENDAR</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#CAMERA">CAMERA</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#CAMERA">CAMERA</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#CONTACTS">CONTACTS</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#READ_CONTACTS">READ_CONTACTS</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#WRITE_CONTACTS">WRITE_CONTACTS</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#GET_ACCOUNTS">GET_ACCOUNTS</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#LOCATION">LOCATION</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#ACCESS_FINE_LOCATION">ACCESS_FINE_LOCATION</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#ACCESS_COARSE_LOCATION">ACCESS_COARSE_LOCATION</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#MICROPHONE">MICROPHONE</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#RECORD_AUDIO">RECORD_AUDIO</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#PHONE">PHONE</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#READ_PHONE_STATE">READ_PHONE_STATE</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#CALL_PHONE">CALL_PHONE</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#READ_CALL_LOG">READ_CALL_LOG</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#WRITE_CALL_LOG">WRITE_CALL_LOG</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#ADD_VOICEMAIL">ADD_VOICEMAIL</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#USE_SIP">USE_SIP</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#PROCESS_OUTGOING_CALLS">PROCESS_OUTGOING_CALLS</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#SENSORS">SENSORS</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#BODY_SENSORS">BODY_SENSORS</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td><code><a href="/reference/android/Manifest.permission_group.html#SMS">SMS</a></code></td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#SEND_SMS">SEND_SMS</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#RECEIVE_SMS">RECEIVE_SMS</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#READ_SMS">READ_SMS</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#RECEIVE_WAP_PUSH">RECEIVE_WAP_PUSH</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#RECEIVE_MMS">RECEIVE_MMS</a></code>
        </li>
      </ul>
    </td>
  </tr>

  <tr>
    <td>
      <code><a href="/reference/android/Manifest.permission_group.html#STORAGE">STORAGE</a></code>
    </td>
    <td>
      <ul>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#READ_EXTERNAL_STORAGE">READ_EXTERNAL_STORAGE</a></code>
        </li>
        <li>
          <code><a href="/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE">WRITE_EXTERNAL_STORAGE</a></code>
        </li>
      </ul>
    </td>
  </tr>

</tbody></table>


### Normal Permissions
http://developer.android.com/intl/ja/guide/topics/security/normal-permissions.html

<p>As of API level 23, the following permissions are classified as <code><a href="/reference/android/content/pm/PermissionInfo.html#PROTECTION_NORMAL">PROTECTION_NORMAL</a></code>:</p>
<ul>
  <li><code><a href="/reference/android/Manifest.permission.html#ACCESS_LOCATION_EXTRA_COMMANDS">ACCESS_LOCATION_EXTRA_COMMANDS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#ACCESS_NETWORK_STATE">ACCESS_NETWORK_STATE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#ACCESS_NOTIFICATION_POLICY">ACCESS_NOTIFICATION_POLICY</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#ACCESS_WIFI_STATE">ACCESS_WIFI_STATE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#BLUETOOTH">BLUETOOTH</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#BLUETOOTH_ADMIN">BLUETOOTH_ADMIN</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#BROADCAST_STICKY">BROADCAST_STICKY</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#CHANGE_NETWORK_STATE">CHANGE_NETWORK_STATE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#CHANGE_WIFI_MULTICAST_STATE">CHANGE_WIFI_MULTICAST_STATE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#CHANGE_WIFI_STATE">CHANGE_WIFI_STATE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#DISABLE_KEYGUARD">DISABLE_KEYGUARD</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#EXPAND_STATUS_BAR">EXPAND_STATUS_BAR</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#FLASHLIGHT">FLASHLIGHT</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#GET_PACKAGE_SIZE">GET_PACKAGE_SIZE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#INTERNET">INTERNET</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#KILL_BACKGROUND_PROCESSES">KILL_BACKGROUND_PROCESSES</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#MODIFY_AUDIO_SETTINGS">MODIFY_AUDIO_SETTINGS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#NFC">NFC</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#READ_SYNC_SETTINGS">READ_SYNC_SETTINGS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#READ_SYNC_STATS">READ_SYNC_STATS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#RECEIVE_BOOT_COMPLETED">RECEIVE_BOOT_COMPLETED</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#REORDER_TASKS">REORDER_TASKS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#REQUEST_INSTALL_PACKAGES">REQUEST_INSTALL_PACKAGES</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#SET_TIME_ZONE">SET_TIME_ZONE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#SET_WALLPAPER">SET_WALLPAPER</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#SET_WALLPAPER_HINTS">SET_WALLPAPER_HINTS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#TRANSMIT_IR">TRANSMIT_IR</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#USE_FINGERPRINT">USE_FINGERPRINT</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#VIBRATE">VIBRATE</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#WAKE_LOCK">WAKE_LOCK</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#WRITE_SYNC_SETTINGS">WRITE_SYNC_SETTINGS</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#SET_ALARM">SET_ALARM</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#INSTALL_SHORTCUT">INSTALL_SHORTCUT</a></code>
  </li>

  <li><code><a href="/reference/android/Manifest.permission.html#UNINSTALL_SHORTCUT">UNINSTALL_SHORTCUT</a></code>
  </li>
</ul>

### デザインガイド  
https://www.google.com/design/spec/patterns/permissions.html

### トレーニング  
http://developer.android.com/intl/ja/training/permissions/index.html

# 公式日本語ブログ

### 実行時パーミッションでさらに優れたアプリを構築する  
http://googledevjp.blogspot.jp/2015/10/blog-post.html

### Google Play 開発者サービス 8.1: Marshmallow への準備開始  
http://googledevjp.blogspot.jp/2015/11/google-play-81-marshmallow.html

### 新しい Android Marshmallow (マシュマロ) のサンプル アプリ  
http://googledevjp.blogspot.jp/2015/12/android-marshmallow.html


# 公式サンプルコード

### Android RuntimePermissions Sample
https://github.com/googlesamples/android-RuntimePermissions

実装部分
https://github.com/googlesamples/android-RuntimePermissions/blob/master/Application/src/main/java/com/example/android/system/runtimepermissions/MainActivity.java


# StackOverflow

実装を進めると大抵の場合、下記の質問にたどり着くのではと思います。

### Never ask again にチェックを入れたことを検知するには
http://stackoverflow.com/questions/30719047/android-m-check-runtime-permission-how-to-determine-if-the-user-checked-nev

### アプリの権限設定を開く
http://stackoverflow.com/questions/32822101/how-to-programmatically-open-the-permission-screen-for-a-specific-app-on-android


# 関連ライブラリ

### PermissionsDispatcher
https://github.com/hotchemi/PermissionsDispatcher

紹介記事
http://qiita.com/kazy/items/0ded30d80cef9df54c98

### Dexter
https://github.com/Karumi/Dexter

### RxPermissions
https://github.com/tbruyelle/RxPermissions


# おまけ

権限の設定画面の誘導時などに SnackBar を使いたい場合はこちら

### SnackBar の表示
http://android-developers.blogspot.jp/2015/05/android-design-support-library.html

### SnackBar の背景、テキストカラーを変える
http://stackoverflow.com/questions/30520625/what-is-new-features-of-android-design-support-library-and-how-to-use-its-snackb?rq=1