Question: In android studio, with Google Maps API, is there a way to continously change the fill color of a polygon triggered by an iot device?
In android studio, with Google Maps API, is there a way to continously change the fill color of a polygon triggered by an iot device?
What i have:
public class MapsActivity extends AppCompatActivity implements ...
{
...
...
private void stylePolygon(Polygon polygon) { ...
switch (type) { case "p1": pattern = PATTERN_POLYGON_ALPHA; if (Sensor1 == 1) { //Sensor1 has the data from the cloud fillColor=COLOR_GREEN_ARGB; strokeColor=COLOR_GREEN_ARGB; } else { fillColor=0xFFD32F2F; //red strokeColor=0xFFD32F2F; } break; ...
}
polygon.setStrokePattern(pattern); polygon.setStrokeWidth(POLYGON_STROKE_WIDTH_PX); polygon.setStrokeColor(strokeColor); polygon.setFillColor(fillColor); }
...
//a function to run other functions every second private Handler handler = new Handler(); private Runnable runnable = new Runnable() { @Override public void run() { new FetchIotData().execute(); //class that fetches and updates Sensor1 data handler.postDelayed(this, 1000); } };
handler.postDelayed(runnable, 1000); ... ... } Using while or do while loop in the switch statement crashes the app
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
