Thursday, June 21, 2012

Change Loud & Silent Mode Programmatically In Android


Here i have explained about changing Loud mode to Silent mode and Silent mode to Loud mode programmatically in android.ProfileChanger
Code

public class ProfileChangerActivity extends Activity {
/** Called when the activity is first created. */

ToggleButton tbt;
TextView txtview;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

tbt = (ToggleButton) findViewById(R.id.togglebutton);
txtview = (TextView) findViewById(R.id.textview);
txtview.setText("Welcome to Profile Changer Application");
final AudioManager mobilemode = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);

tbt.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub

if(tbt.getText().toString().equals("Switch to LOUD"))
{
mobilemode.setRingerMode(AudioManager.RINGER_MODE_SILENT);
txtview.setText("SILENT profile activated !");
Toast.makeText(getBaseContext(),"SILENT profile activated ",Toast.LENGTH_LONG).show();
}
else if(tbt.getText().toString().equals("Switch to SILENT"))
{
mobilemode.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
txtview.setText("LOUD profile activated !");
Toast.makeText(getBaseContext(),"LOUD profile activated !",Toast.LENGTH_LONG).show();

}

}
});
}
}


Here is your output.



You can download the source here
Arun Kumar Munusamy Web Developer

Morbi aliquam fringilla nisl. Pellentesque eleifend condimentum tellus, vel vulputate tortor malesuada sit amet. Aliquam vel vestibulum metus. Aenean ut mi aucto.

5 comments:

  1. Earn from Ur Website or Blog thr PayOffers.in!

    Hello,

    Nice to e-meet you. A very warm greetings from PayOffers Publisher Team.

    I am Sanaya Publisher Development Manager @ PayOffers Publisher Team.

    I would like to introduce you and invite you to our platform, PayOffers.in which is one of the fastest growing Indian Publisher Network.

    If you're looking for an excellent way to convert your Website / Blog visitors into revenue-generating customers, join the PayOffers.in Publisher Network today!


    Why to join in PayOffers.in Indian Publisher Network?

    * Highest payout Indian Lead, Sale, CPA, CPS, CPI Offers.
    * Only Publisher Network pays Weekly to Publishers.
    * Weekly payments trough Direct Bank Deposit,Paypal.com & Checks.
    * Referral payouts.
    * Best chance to make extra money from your website.

    Join PayOffers.in and earn extra money from your Website / Blog

    http://www.payoffers.in/affiliate_regi.aspx

    If you have any questions in your mind please let us know and you can connect us on the mentioned email ID info@payoffers.in

    I’m looking forward to helping you generate record-breaking profits!

    Thanks for your time, hope to hear from you soon,
    The team at PayOffers.in

    ReplyDelete
  2. Is is possible to switch to outdoor and other customized user profiles?

    ReplyDelete
  3. Thanks for sharing useful information we are provide best service.

    Videocon has come with a wide range of Value Added Services including Caller Tunes, Sports, VRashi(Horoscope), News and Entertainment. A lot of new exciting services are going to be in the list to rock!Videocon has also started GPRS services, which is free for couple of days .

    ReplyDelete