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

Maximize Your Skills with Online Business English

Hey there! If you're looking to boost your English skills, especially in a business context,…

4 days ago

Exploring the Features of Elf Bar BC20000

Hello, fellow vapers and the vape-curious! If you find yourself wandering through the expansive universe…

4 days ago

Brazil’s Role in Shaping BRICS Leadership

By John Kaweske Hey there! So, have you ever wondered what Brazil is up to…

1 week ago

Why Amazon4D Gacor Slots Are Popular

Before we dive into the specifics of Amazon4D Gacor Slots, let's take a quick detour…

1 week ago

Mastering Business Casual for Men: A Complete Style Guide

Organizational casual is the sweet location between professional and tranquil. It allows men to look…

2 weeks ago

Tips for Maximizing Your QQDewa Experience

Understanding QQDewa Basics First things first, what's QQDewa all about? Simply put, QQDewa is an…

2 weeks ago