Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set the volume to 50% when the app starts #26

Merged
merged 3 commits into from
Jul 10, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Licensed to the Apache Software Foundation (ASF) under one

package com.maq.xprize.cci.hindi;

import android.content.Context;
import android.media.AudioManager;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
Expand All @@ -28,6 +30,9 @@ Licensed to the Apache Software Foundation (ASF) under one
import java.io.File;

public class MainActivity extends CordovaActivity {
AudioManager audioManager; //declaring audio manager object
private int maxVolume;
RickyRiko305 marked this conversation as resolved.
Show resolved Hide resolved

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -47,5 +52,10 @@ public void onCreate(Bundle savedInstanceState) {
// update file path as per the storage preference
launchUrl = "file:///" + SplashScreenActivity.assetsPath + File.separator + "www/index.html";
loadUrl(launchUrl);
audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); //maximum value of stream media.
if (audioManager.getStreamVolume(AudioManager.STREAM_MUSIC) < maxVolume / 2) { //check if the audio is less than 50%
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, maxVolume / 2, 0); //set the audio to 50% when app start.
}
}
}