Android: How to initialize a variable of type “Location” (other than making it equal to null)

前端 未结 4 1723
花落未央
花落未央 2021-02-11 12:20

I\'m looking to test some code I\'ve written and to do so I need to construct a variable of type Location and to give it a long / lat value but I\'m unsure how I would do so. An

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-11 12:38

    Location object = new Location("service Provider");
    

    it will create an object of Type Location that contains the initial Latitude and Longitude at location '0' to get the initial values use

    double lat = object.getLatitude();
    double lng = object.getLongitude();
    

提交回复
热议问题