Why does the street view not work?

Why does the street view not work?
everything works exept for the first line

package com.app.maps1.fragments;

import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.provider.Settings;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.app.maps1.R;
import com.google.android.gms.maps.CameraUpdate;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link MapFragment#newInstance} factory method to
 * create an instance of this fragment.
 */
public class MapFragment extends Fragment implements OnMapReadyCallback, GoogleMap.OnMarkerDragListener {

    private View rootView;
    private MapView mapView;
    private GoogleMap gMap;

    private Geocoder geocoder; //para obtener localizacion
    private List<Address> addresses;

    private MarkerOptions marker; //para customizar marcador

    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    private static final String ARG_PARAM1 = "param1";
    private static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public MapFragment() {
        // Required empty public constructor
    }

    /**
     * Use this factory method to create a new instance of
     * this fragment using the provided parameters.
     *
     * @param param1 Parameter 1.
     * @param param2 Parameter 2.
     * @return A new instance of fragment MapFragment.
     */
    // TODO: Rename and change types and number of parameters
    public static MapFragment newInstance(String param1, String param2) {
        MapFragment fragment = new MapFragment();
        Bundle args = new Bundle();
        args.putString(ARG_PARAM1, param1);
        args.putString(ARG_PARAM2, param2);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        rootView = inflater.inflate(R.layout.fragment_map, container, false);
        return rootView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        mapView = (MapView) rootView.findViewById(R.id.map);
        if (mapView != null){
            mapView.onCreate(null);
            mapView.onResume();
            mapView.getMapAsync(this);
        }
       // this.checkIfGPSIsEnabled();
    }

    /*@Override
    public void onResume() {
        super.onResume();
        this.checkIfGPSIsEnabled();
    }*/

    @Override
    public void onMapReady(@NonNull GoogleMap googleMap) {

        gMap = googleMap;

        LatLng torreon = new LatLng(25.53986916895781, -103.40568068906825);

        // solo para zoom
        CameraUpdate zoom = CameraUpdateFactory.zoomTo(15);

        //para customizar marcador
        marker = new MarkerOptions();
        marker.position(torreon);
        marker.title("Mi marcador");
        marker.draggable(true);
        marker.snippet("Esto es una caja de texto donde se modifican los datos");
        marker.icon(BitmapDescriptorFactory.fromResource(android.R.drawable.star_on));

        gMap.addMarker(marker);
        //gMap.addMarker(new MarkerOptions().position(torreon).title("Estas en Torres").draggable(true));
        gMap.moveCamera(CameraUpdateFactory.newLatLng(torreon));
        gMap.animateCamera(zoom);

        gMap.setOnMarkerDragListener(this);

        geocoder = new Geocoder(getContext(), Locale.getDefault());

        //CameraPosition camera = new CameraPosition.Builder()
                //.target(torreon)
                //.zoom(13) // limite 21
                //.bearing(0) //rotacion de camara al este 365º
                //.tilt(0)  // vista 3D limite 90
                //.build();
        //gMap.animateCamera(CameraUpdateFactory.newCameraPosition(camera));

    }

  /*  private void checkIfGPSIsEnabled(){
        try {
            int gpsSignal = Settings.Secure.getInt(getActivity().getContentResolver(), Settings.Secure.LOCATION_MODE);

            if (gpsSignal == 0){
                //gps no activado
                Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(intent);
            }
        } catch (Settings.SettingNotFoundException e) {
            e.printStackTrace();
        }
    }*/

    @Override
    public void onMarkerDragStart(@NonNull Marker marker) {
        marker.hideInfoWindow();
    }

    @Override
    public void onMarkerDrag(@NonNull Marker marker) {

    }

    @Override
    public void onMarkerDragEnd(@NonNull Marker marker) {
        double latitude = marker.getPosition().latitude;
        double longitude = marker.getPosition().longitude;

        try {
            addresses = geocoder.getFromLocation(latitude, longitude, 1);
        } catch (IOException e) {
            e.printStackTrace();
        }

        String address = addresses.get(0).getAddressLine(0);
        String city = addresses.get(0).getLocality(); //ciudad
        String state = addresses.get(0).getAdminArea(); //estado
        String country = addresses.get(0).getCountryName(); //pais
        String postalCode = addresses.get(0).getPostalCode();//codigo postal

        //informacion en caja de marcador
        //marker.setSnippet( city + ", " + country + " ( " + postalCode + " )");
        //para mostrar info de snippet al soltar marcador
        marker.showInfoWindow();

       Toast.makeText(getContext(), "address: " + address + "\n" +
                "city: " + city + "\n" +
                "state: " + state + "\n" +
                "country: " + country + "\n" +
                "postal code: " + postalCode + "\n"
                , Toast.LENGTH_LONG).show();
        }
    }
}

Hey i think this is not the processing language so you should tag this post with p5js :slight_smile:

oh sorry, i didnt know. i found it on internet. that also answers my question. ill have to change it to the other one i found

@MoonAlien822,

Please read:

You have edited your post from javaScript code to Android code.

Your most recent edit is identical to Android code from here:
Problem with google maps app: java.lang.NullPointerException – Cloud Stack Ninja

If you have a question related to Processing (or one of the related categories):

  • Read the guidelines first before posting a topic.
  • Ask the question with some context to what you are trying to do.
  • Tag your post with the correct category.
  • Provide a link to the source of the original code.

That should be:

I found it on the Internet.

You may want to consider going over to Stack Overflow with Android questions that are not related to Processing.