Question: Hello, can you please add to my gps code on android studio that uses api 2 7 . I sent it to 3 experts and
Hello, can you please add to my gps code on android studio that uses api I sent it to experts and none of them did what i wanted. I will send you my code of mainactivity.java and I want you to add to my app, right now it can only record the ip adress but I want you to add an option to tell the user to add the country they went to and to rate it out of stars and tweak the code to display past ip locations and star rating aka permanent database. Please make a colorful xml code for the ui Please dont overthink it and make it simple as long as it has all of the above functions I am ok with what it looks like
mainactivity.java:
package com.example.simplegpsapp;
import android.Manifest;
import android.content.pmPackageManager;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.osBundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity
private TextView locationTextView;
private LocationManager locationManager;
private final ArrayList locationList new ArrayList;
private ArrayAdapter adapter;
@Override
protected void onCreateBundle savedInstanceState
super.onCreatesavedInstanceState;
setContentViewRlayout.activitymain;
locationTextView findViewByIdRidlocationTextView;
Button recordLocationButton findViewByIdRidrecordLocationButton;
Button viewLocationsButton findViewByIdRidviewLocationsButton;
ListView locationListView findViewByIdRidlocationListView;
Initialize Location Manager
locationManager LocationManager getSystemServiceLOCATIONSERVICE;
Set up ListView adapter
adapter new ArrayAdapterthis android.Rlayout.simplelistitem locationList;
locationListView.setAdapteradapter;
Record location button functionality
recordLocationButton.setOnClickListenernew View.OnClickListener
@Override
public void onClickView v
getLocation;
;
View saved locations button functionality
viewLocationsButton.setOnClickListenernew View.OnClickListener
@Override
public void onClickView v
adapter.notifyDataSetChanged;
Toast.makeTextMainActivitythis, "Showing saved locations", Toast.LENGTHSHORTshow;
;
private void getLocation
if ActivityCompatcheckSelfPermissionthis Manifest.permission.ACCESSFINELOCATION PackageManager.PERMISSIONGRANTED &&
ActivityCompat.checkSelfPermissionthis Manifest.permission.ACCESSCOARSELOCATION PackageManager.PERMISSIONGRANTED
ActivityCompat.requestPermissionsthis new StringManifestpermission.ACCESSFINELOCATION;
return;
locationManager.requestSingleUpdateLocationManagerGPSPROVIDER, new LocationListener
@Override
public void onLocationChanged@NonNull Location location
String locationText "Lat: location.getLatitude Lon: location.getLongitude;
locationTextView.setTextlocationText;
locationList.addlocationText;
Toast.makeTextMainActivitythis, "Location Recorded", Toast.LENGTHSHORTshow;
@Override
public void onStatusChangedString provider, int status, Bundle extras
@Override
public void onProviderEnabled@NonNull String provider
@Override
public void onProviderDisabled@NonNull String provider
null;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
