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 Best Marketing Agencies in Sacramento

Sacramento's premier marketing agencies deliver top-quality service at a highly competitive rate. They tailor strategies…

6 months ago

IAAI Bid History

IAAI provides various services that enable buyers and sellers to acquire or dispose of vehicles…

6 months ago

The most recent News From Cyprus

Cyprusnews is an online news site that provides up-to-the-minute protection and is committed to self-reliance,…

6 months ago

Executive CV Writing Services

Executive CV writing services specialize in crafting well-written documents that attract recruiters' interest. They also…

6 months ago

Understanding the Costs of Earning a Commercial Pilot License

Introduction: Overview of Becoming a Commercial Pilot Becoming a commercial pilot is not just about…

6 months ago

The Best Forex Trading Platform For Beginners

Beginners looking to start trading forex should choose a platform with plenty of educational materials,…

6 months ago