在运行时使用片段的Android权限

在运行时使用片段的Android权限,android,android-mapview,android-6.0-marshmallow,runtime-permissions,Android,Android Mapview,Android 6.0 Marshmallow,Runtime Permissions,我的项目中有一个活动,在xml(主)中有两个片段: 如你们所见,其中一个是地图片段。 问题是当setContentView()运行时,应用程序在API 23以上崩溃。 在setContentView()之前,我尝试使用进行(位置)权限检查,但应用程序仍然崩溃。 有什么想法吗?尝试用以下方式更改代码: <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout

我的项目中有一个活动,在xml(主)中有两个片段:


如你们所见,其中一个是地图片段。 问题是当
setContentView()
运行时,应用程序在API 23以上崩溃。 在
setContentView()
之前,我尝试使用进行(位置)权限检查,但应用程序仍然崩溃。
有什么想法吗?

尝试用以下方式更改代码:

<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.SupportMapFragment"/>


显示地图不需要任何权限。只有在访问用户位置时才需要权限。张贴你的活动代码。谢谢Jyotman Singh,你的回答让我明白我错过了什么。。
<fragment
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.SupportMapFragment"/>