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 Ultimate Guide to YouTube to MP4 Converters

A YouTube to MP4 conversion software is a software or on-the-web tool designed to download…

2 days ago

Unox Equipment: A Chef’s Companion

Cooking is an art, and each artist needs the right equipment to bring their masterpiece…

2 days ago

Comparing Electric Scooters: Features and Performance

Hey there, scooter enthusiast! Whether you're a seasoned rider or just thinking about zipping around…

2 days ago

Discovering Affordable Massage Services throughout Busan

Hey there, massage fans! If you're in Busan and also searching for a way to…

2 days ago

Guide to Aroma Massage Services in Busan

Hey there! If you're planning a trip to Busan, or if you're already here and…

2 days ago

Is Instant Famous Worth It? A Detailed Review of Their Follower Services

Are you looking for ways to get more followers on your social media accounts to…

3 days ago