Categories: ANDROID APP

The best way to alter the quantity of your Android Telephone programmatically out of your App? – Supply code



This video reveals the steps to create a quantity controller App in your Android Telephone. This video first creates a easy structure with quantity up and down button and makes use of a seekbar to indicate the present stage of the quantity.

For any question, ideas or appreciations, we will likely be glad to listen to from you at: programmerworld1990@gmail.com

https://programmerworld.co/android/how-to-adjust-the-volume-of-your-android-phone-programmatically-from-your-app-source-code/

Full Java code used on this tutorial may be discovered under:

bundle com.instance.myvolumecontroller;

import android.content material.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
non-public SeekBar seekBar;
non-public AudioManager audioManager;

@Override
protected void onCreate(Bundle savedInstanceState) {
tremendous.onCreate(savedInstanceState);
setContentView(R.structure.activity_main);

seekBar = findViewById(R.id.seekBar);
audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
seekBar.setMax(audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC));
seekBar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
}

public void UpButton(View view){
audioManager.adjustVolume(AudioManager.ADJUST_RAISE, AudioManager.FLAG_PLAY_SOUND);
seekBar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
Toast.makeText(this,”Quantity Up”, Toast.LENGTH_SHORT).present();
}

public void DownButton(View view){
audioManager.adjustVolume(AudioManager.ADJUST_LOWER, AudioManager.FLAG_PLAY_SOUND);
seekBar.setProgress(audioManager.getStreamVolume(AudioManager.STREAM_MUSIC));
Toast.makeText(this,”Quantity Down”, Toast.LENGTH_SHORT).present();
}
}

source

linda

Recent Posts

The Biggest Poker Prizes in History

Introduction Poker has long been more than just a card game—it’s a world where strategy,…

18 hours ago

Affordable and Flexible Auto Loans at Haverhill Bank

Buying a vehicle gives you freedom, convenience, and flexibility. Whether it’s an initial car or…

22 hours ago

Security Features of Leading Crypto Exchanges

Hey there, crypto enthusiasts! If you're diving into the world of cryptocurrencies, you know that…

2 days ago

Fast and Flexible Business Loans with Traceloans.com

Introduction: Are you ready to scale your company? Traceloans. Com business loans provide the financial…

2 days ago

Choosing the Right Paving Contractor in Hayward

When it comes to transforming outdoor spaces into stunning, durable, and functional areas, paving contractors…

4 days ago

Tips for a Successful Russian Visa Application

Applying for a Russian visa might initially seem like a complex and intimidating task, but…

1 week ago