Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8079111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:00:12+00:00 2026-06-05T16:00:12+00:00

I am making an android application to show the position of a user on

  • 0

I am making an android application to show the position of a user on a map, along with the users current longitude and latitude, I have also used reverse geocoding to show the address of the android device. Now I plan to add a feature that if the user is near a particular place the phone automatically switches to silent mode, for this I have made a function to check whether the phone is already silent or not. Now I want to make another one, which puts the phone in silent mode on nearing a particular location.

The method which I have made to make the phone go silent on nearing a particular location is

public void changeToSilent(Location location){

    if(distanceTo(xxxx)<100)
    {
        if(mPhoneIsSilent==true){
        }
        else
        {
            mPhoneIsSilent = true;
            mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        }
    }
}

Now I am calling this method in another function, which is….

public void onLocationChanged(Location location)
{
Log.d(TAG, “onLocationChanged with location ” + location.toString()); Stringtext=String.format(“Lat:\t%f\nLong:\t%f\nAlt:\t%f\nBearing:\t%f”,location.getLatitude(),location.getLongitude(), location.getAltitude(), location.getBearing());
this.locationText.setText(text);

    changeToSilent(location);

    try {
      List<Address> addresses = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 10); 
      for (Address address : addresses) {
        this.locationText.append("\n" + address.getAddressLine(0));
      }

      int latitude = (int)(location.getLatitude() * 1000000);
      int longitude = (int)(location.getLongitude() * 1000000);

      GeoPoint point = new GeoPoint(latitude,longitude);
      mapController.animateTo(point); 

    } catch (IOException e) {
      Log.e("LocateMe", "Could not get Geocoder data", e);

    }
  }

Now I am calling the above function in the oncreate method. Now suppose I know the latitude and longitude of the place near which the phone should go to silent.
What I want to know is, what do I have to write in place of xxxx in the changetosilent method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:00:18+00:00Added an answer on June 5, 2026 at 4:00 pm

    You can use the AudioManager to change the system volume levels.

    here is an example:

    AudioManager am =  (AudioManager) getSystemService(AUDIO_SERVICE); 
    //am.setStreamVolume(AudioManager.STREAM_MUSIC,6,0); //<-- use this one to set the volume
    am.setRingerMode(AudioManager.RINGER_MODE_SILENT); //<-- to put on mute.
    

    EDIT: Get a Location object and use loc.distanceBetween();

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a small Android application to show current total CPU usage like tab
I am making an Android application. In my application, I have to find the
I am making the phonegap android application in html,javascript and jquery.I have made the
So as of current I am making an Android application with multiple layout files
I am making an application for android which should show pictures (i was already
I am making an android application in which I have put 10 images and
I'm making an android application in which I want to show Punjabi text in
im making an android application which requires a user to register using a form
Hey guys, i am making an android application where i want to show a
I am making an android application that shows a list with users, I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.