前提・実現したいこと
CheckSelfPermissionがうまくいきません
manifestには
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
を書いているのですが、実際に
PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION))
PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION))
をするとfalseになります。
該当のソースコード
kotlin
1 if ((PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) and 2 (PackageManager.PERMISSION_GRANTED == ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION))) 3 { 4 Log.w(TAG, "hoge") 5 }
xml
1<?xml version="1.0" encoding="utf-8"?> 2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.example.hoge" 4 android:installLocation="auto" 5> 6 7 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 8 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 9 10 11 <application 12 android:allowBackup="true" 13 android:icon="@mipmap/ic_launcher" 14 android:label="@string/app_name" 15 android:roundIcon="@mipmap/ic_launcher_round" 16 android:supportsRtl="true" 17 android:theme="@style/AppTheme"> 18 <activity android:name=".MainActivity"> 19 <intent-filter> 20 <action android:name="android.intent.action.MAIN"/> 21 22 <category android:name="android.intent.category.LAUNCHER"/> 23 </intent-filter> 24 </activity> 25 </application> 26 27</manifest> 28
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/07 15:27