Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected void onPause(){
- super.onPause();
- try {
- // Modes: MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITABLE
- FileOutputStream output = openFileOutput("latlngpoints.txt",
- Context.MODE_PRIVATE);
- DataOutputStream dout = new DataOutputStream(output);
- dout.writeInt(listPoints.size()); // Save line count
- for (LatLng point : listPoints) {
- dout.writeUTF(point.latitude + "," + point.longitude);
- Log.v("write", point.latitude + "," + point.longitude);
- }
- dout.flush(); // Flush stream ...
- dout.close(); // ... and close.
- } catch (IOException exc) {
- exc.printStackTrace();
- }
- }
- protected void onResume(GoogleMap googleMap) {
- super.onResume();
- try {
- FileInputStream input = openFileInput("latlngpoints.txt");
- DataInputStream din = new DataInputStream(input);
- int sz = din.readInt(); // Read line count
- for (int i = 0; i < sz; i++) {
- String str = din.readUTF();
- String[] stringArray = str.split(",");
- double latitude = Double.parseDouble(stringArray[0]);
- double longitude = Double.parseDouble(stringArray[1]);
- // newlist.add(new LatLng(latitude, longitude));
- Log.v("Read", String.valueOf(latitude));
- Log.v("Read1", String.valueOf(longitude));
- LatLng latLng = new LatLng(Double.parseDouble(stringArray[0]),Double.parseDouble(stringArray[1]));
- mMap1 = googleMap;
- mMap1.addCircle(new CircleOptions()
- .center(latLng)
- .radius(100)
- .strokeColor(Color.RED));
- }
- din.close();
- } catch (IOException exc) {
- exc.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement