-4

I am getting an error "Cannot resolve method 'maketext (android.content.Context, java.lang.String, java.lang.String, int ')". I assume that there is some problem with the altitude part (int). Can someone tell me how to fix this?

    @OnClick(R.id.btn_get_last_location)
        public void showLastKnownLocation() {
            if (mCurrentLocation != null) {
                Toast.makeText(getApplicationContext(), "Lat: " + mCurrentLocation.getLatitude()
                + ", Lng: " + mCurrentLocation.getLongitude(), ", Alt: " + mCurrentLocation.getAltitude(), Toast.LENGTH_LONG).show();
            } 
        else
            {
                Toast.makeText(getApplicationContext(), "Last known location is not available!", Toast.LENGTH_SHORT).show();
            }
        }
Markus Kauppinen
  • 3,025
  • 4
  • 20
  • 30
Annie
  • 1
  • 8

2 Answers2

1

Replace

 Toast.makeText(getApplicationContext(), "Lat: " + mCurrentLocation.getLatitude()
            + ", Lng: " + mCurrentLocation.getLongitude(), ", Alt: " + mCurrentLocation.getAltitude(), Toast.LENGTH_LONG).show();

with

 Toast.makeText(getApplicationContext(), "Lat: " + mCurrentLocation.getLatitude()
            + ", Lng: " + mCurrentLocation.getLongitude() + ", Alt: " + mCurrentLocation.getAltitude(), Toast.LENGTH_LONG).show();
Zun
  • 1,553
  • 3
  • 15
  • 26
0

Use this

           Toast.makeText(getActivity(), "Lat: " + mCurrentLocation.getLatitude() + ", Lng: " + mCurrentLocation.getLongitude() + ", Alt: " + mCurrentLocation.getAltitude(), Toast.LENGTH_LONG).show();

Instead of this

              Toast.makeText(getApplicationContext(), "Lat: " + mCurrentLocation.getLatitude()
            + ", Lng: " + mCurrentLocation.getLongitude(), ", Alt: " + mCurrentLocation.getAltitude(), Toast.LENGTH_LONG).show();

But This is not the best approach,According to the android Documentations use string with place holder. String With Place Holders

scienticious
  • 438
  • 1
  • 7
  • 22
  • Thankyou Scienticious. I modified it. Now I have another error "Cannot resolve symbol R" and "No enum constant com.android.manifmerger.AttributeOperationType.CONTEXT". I tried to clean project --> rebuild, invalidating catches & restarting but nothing seems to work. – Annie Jul 09 '18 at 16:33
  • I need to wait for another 4 days to post a question..Ufff:( – Annie Jul 09 '18 at 16:34