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

Essential Tips for Successful Condo Renovation

Before embarking on the renovation journey, it's crucial to comprehend what the process involves. Condo…

16 hours ago

Tips on how to Maximize Your Glory Casino Benefit

Hey there, fellow casino lover! If you're on the hunt to help make the most…

23 hours ago

How to Maximize Wins on Glory Casino

Hey there, fellow gaming enthusiast! Are you ready to dive into the exciting world of…

2 days ago

Best Private Universities to Consider throughout Turkey

Hey there! So you're interested in studying in Turkey? That's a fantastic choice! Egypt is…

2 days ago

Best Benefits of Harbor City Hemp

Welcome to the world of Harbor Town Hemp! If you're curious about exactly how hemp…

4 days ago

Common Issues with Gear Pumps and Solutions

Before we discuss the issues, let's quickly review what a gear pump is. A gear…

4 days ago