第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

片段中函數(shù)的無法訪問語句

片段中函數(shù)的無法訪問語句

藍(lán)山帝景 2023-10-12 15:01:25
我有一個(gè)片段,我想在其中顯示地圖,我現(xiàn)在已經(jīng)這樣做了,但是當(dāng)我調(diào)用函數(shù)時(shí),它會(huì)拋出一個(gè)無法訪問的錯(cuò)誤。public class HomeFragment extends Fragment { private static final String TAG = "HomeFragment"; private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION; private static final String COARSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION; //vars private Boolean mLocationPermissionsGranted = false; private static final int LOCATION_PERMISSION_REQUEST_CODE = 1234; private GoogleMap mMap; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {  return inflater.inflate(R.layout.layout_home, container, false);  getLocationPermision(); } private void initMap() {  SupportMapFragment mapFragment = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);  mapFragment.getMapAsync(new OnMapReadyCallback() {   @Override   public void onMapReady(GoogleMap googleMap) {    mMap = googleMap;   }  }); } private void getLocationPermision() {  String[] permissions = {   Manifest.permission.ACCESS_FINE_LOCATION,   Manifest.permission.ACCESS_COARSE_LOCATION  };  if (ContextCompat.checkSelfPermission(this.getActivity().getApplicationContext(), FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {   if (ContextCompat.checkSelfPermission(this.getActivity().getApplicationContext(), COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {    mLocationPermissionsGranted = true;   }  } else {   ActivityCompat.requestPermissions(this.getActivity(), permissions, LOCATION_PERMISSION_REQUEST_CODE);  } }當(dāng)我嘗試打電話時(shí)getLocationPermission()它讓我你能幫我一下嗎?我應(yīng)該在主要活動(dòng)中進(jìn)行這些權(quán)限驗(yàn)證嗎?在主要活動(dòng)中,我只有一個(gè)導(dǎo)航欄,當(dāng)然我想處理片段。
查看完整描述

1 回答

?
慕妹3242003

TA貢獻(xiàn)1824條經(jīng)驗(yàn) 獲得超6個(gè)贊

@Nullable

@Override

public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    return inflater.inflate(R.layout.layout_home,container,false);


    getLocationPermision();

}

getLocationPermision();在您的 return 語句之后調(diào)用。使其無法到達(dá)。


將其移至 return 語句之前。


查看完整回答
反對(duì) 回復(fù) 2023-10-12
  • 1 回答
  • 0 關(guān)注
  • 100 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)