Example usage for android.media AudioManager getStreamMaxVolume

List of usage examples for android.media AudioManager getStreamMaxVolume

Introduction

In this page you can find the example usage for android.media AudioManager getStreamMaxVolume.

Prototype

public int getStreamMaxVolume(int streamType) 

Source Link

Document

Returns the maximum volume index for a particular stream.

Usage

From source file:usbong.android.retrocc.UsbongDecisionTreeEngineActivity.java

public void init() {
    //if return is null, then currScreen=0
    //        currScreen=Integer.parseInt(getIntent().getStringExtra("currScreen")); 
    //modified by JPT, May 25, 2015
    if (getIntent().getStringExtra("currScreen") != null) {
        currScreen = Integer.parseInt(getIntent().getStringExtra("currScreen"));
    }/*w w w  . j  a  v  a2  s  .  c om*/

    //updated by Mike, 20160608
    /*        
            currLanguageBeingUsed=UsbongUtils.LANGUAGE_ENGLISH;
          UsbongUtils.setCurrLanguage("English"); //added by Mike, 22 Sept. 2015
    */
    //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
    //; last accessed: 9 June 2015
    //answer by Elenasys
    //added by Mike, 9 June 2015
    SharedPreferences prefs = getSharedPreferences(UsbongConstants.MY_SAVED_LANGUAGE_SETTING, MODE_PRIVATE);
    if (prefs != null) {
        //@todo: remove this id thing, immediately use the String; otherwise it'll be cumbersome to keep on adding language ids
        currLanguageBeingUsed = prefs.getInt("preferredLanguage",
                UsbongUtils.getLanguageID(UsbongUtils.getCurrLanguage())); //default is Filipino
        /* //commented out by Mike, 20160608
         * //default language will be set based on the default language set in the .xml of the .utree file
         *         UsbongUtils.setDefaultLanguage(UsbongUtils.getLanguageBasedOnID(currLanguageBeingUsed));
         */
        UsbongUtils.setCurrLanguage(UsbongUtils.getLanguageBasedOnID(currLanguageBeingUsed));//prefs.getInt("preferredLanguage", 0))); //updated by Mike, 20160612
    } else {
        //default..
        currLanguageBeingUsed = UsbongUtils.getLanguageID(UsbongUtils.getCurrLanguage());
        //UsbongUtils.setCurrLanguage(UsbongUtils.getLanguageBasedOnID(currLanguageBeingUsed)); //updated by Mike, 20160612
    }

    /*       //commented out by Mike, 20160618
     *       //why? the index numbers used by currSelectedItemForSetLanguage does not always match with currLanguageBeingUsed
     *        //added by Mike, 20160608
     *        currSelectedItemForSetLanguage = currLanguageBeingUsed;
     */
    //==================================================================
    //text-to-speech stuff
    /*//comment out, not needed in DAHON, 
    * commented out by Mike, 20160613
    Intent checkIntent = new Intent();
    checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
    startActivityForResult(checkIntent, UsbongUtils.MY_DATA_CHECK_CODE);
    */
    mTts = new TextToSpeech(this, this);
    mTts.setLanguage(new Locale("en", "US"));//default
    //==================================================================

    myMediaPlayer = new MediaPlayer();
    myMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); //added by Mike, 22 July 2015
    myMediaPlayer.setVolume(1.0f, 1.0f);

    //added by Mike, 25 Sept. 2015
    myBGMediaPlayer = new MediaPlayer();
    myBGMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    myBGMediaPlayer.setVolume(0.5f, 0.5f);

    //added by Mike, 22 July 2015
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    am.setStreamVolume(AudioManager.STREAM_MUSIC, am.getStreamMaxVolume(AudioManager.STREAM_MUSIC), 0);

    usbongNodeContainer = new Vector<String>();
    classificationContainer = new Vector<String>();
    radioButtonsContainer = new Vector<String>();
    usbongAnswerContainer = new Vector<String>();
    checkBoxesContainer = new Vector<String>();
    decisionTrackerContainer = new Vector<String>();

    usedBackButton = false;
    currAnswer = "";

    try {
        //commented out by Mike, 4 Oct. 2015
        UsbongUtils.createUsbongFileStructure();

        //added by Mike, 20160417
        UsbongUtils.initUsbongConfigFile();

        //create the usbong_demo_tree and store it in sdcard/usbong/usbong_trees
        //          UsbongUtils.storeAssetsFileIntoSDCard(this,"usbong_demo_tree.xml");
        /*          UsbongUtils.storeAssetsFileIntoSDCard(this,UsbongUtils.DEFAULT_UTREE_TO_LOAD+".utree");
         */
        //edited by Mike, 20160119
        UsbongUtils.storeAssetsFileIntoSDCard(this, UsbongConstants.TREE_TYPE_SELL + ".utree");
        UsbongUtils.storeAssetsFileIntoSDCard(this, UsbongConstants.TREE_TYPE_REQUEST + ".utree");
        UsbongUtils.storeAssetsFileIntoSDCard(this, UsbongConstants.TREE_TYPE_BUY + ".utree"); //added by Mike, 20160126           

        //added by Mike, 20160126
        UsbongUtils.storeAssetsFileIntoSDCard(this, UsbongConstants.ITEMS_LIST_COMICS + ".txt");
        UsbongUtils.storeAssetsFileIntoSDCard(this, UsbongConstants.ITEMS_LIST_TOYS + ".txt");
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

    //Reference: http://stackoverflow.com/questions/2793004/java-lista-addalllistb-fires-nullpointerexception
    //Last accessed: 14 March 2012
    attachmentFilePaths = new ArrayList<String>();
    //      attachmentFilePaths.clear();
    //      System.out.println(">>>>>>>>> attachmentFilePaths.clear!");
    currAudioRecorder = null;

    myQRCodeContent = "";
    hasReturnedFromAnotherActivity = false; //camera, paint, email, etc

    //added by Mike, March 4, 2013
    usbongAnswerContainerCounter = 0;
    /*              
           ArrayList<String> skuList = new ArrayList<String> ();
           skuList.add(UsbongConstants.ALL_LOCAL_LANGUAGES_PRODUCT_ID);
           skuList.add(UsbongConstants.ALL_FOREIGN_LANGUAGES_PRODUCT_ID);
           Bundle querySkus = new Bundle();
           querySkus.putStringArrayList("ITEM_ID_LIST", skuList);
    */

    new AsyncTask<String, Integer, Boolean>() {
        @Override
        protected void onPostExecute(Boolean result) {
            //added by Mike, 20160421
            //init purchase languages list
            purchaseLanguagesListDialog = new AlertDialog.Builder(getInstance());
            myPurchaseLanguageBundleListAdapter = new PurchaseLanguageBundleListAdapter(getInstance(),
                    UsbongUtils.getInAppOwnedItems(), UsbongUtils.getInAppMService());
            purchaseLanguagesListDialog.setTitle("Purchase");
            purchaseLanguagesListDialog.setSingleChoiceItems(myPurchaseLanguageBundleListAdapter, 0,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            //                         Log.i("Selected Item : ", (String) myPurchaseLanguageBundleListAdapter.getItem(which));
                            dialog.dismiss(); //edited by Mike, 20160508                  
                            //                        purchaseLanguagesListDialogInterface = dialog;
                        }
                    });
            purchaseLanguagesListDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
        }

        @Override
        protected Boolean doInBackground(String... params) {
            try {
                UsbongUtils.initInAppBillingService(getInstance());
                UsbongUtils.initInAppBillingService(getInstance()); //need to call this twice to get the updated languageBundleList
            } catch (Exception e) {
                e.printStackTrace();
            }
            return true;
        }
    }.execute();

    //reference: Labeeb P's answer from stackoverflow;
    //http://stackoverflow.com/questions/4275797/view-setpadding-accepts-only-in-px-is-there-anyway-to-setpadding-in-dp;
    //last accessed: 23 May 2013
    final float scale = getResources().getDisplayMetrics().density;
    padding_in_px = (int) (padding_in_dp * scale + 0.5f);

    //added by Mike, 25 June 2013
    UsbongUtils.setDebugMode(UsbongUtils.isInDebugMode());

    //added by Mike, 25 Feb. 2014
    //        UsbongUtils.setStoreOutput(UsbongUtils.checkIfStoreOutput());
    UsbongUtils.setStoreOutput(false); //don't store output, added by Mike, 27 Sept. 2015

    myUsbongScreenProcessor = new UsbongScreenProcessor(UsbongDecisionTreeEngineActivity.getInstance());
    myUsbongVariableMemory = new HashMap<String, String>();
    /*
           //Reference: http://stackoverflow.com/questions/23024831/android-shared-preferences-example
            //; last accessed: 20150609
            //answer by Elenasys
            //added by Mike, 20150207
            prefs = getSharedPreferences(UsbongConstants.MY_ACCOUNT_DETAILS, MODE_PRIVATE);
            if (prefs!=null) {
             setVariableOntoMyUsbongVariableMemory("firstName", prefs.getString("firstName", ""));//"" is the default value.
             setVariableOntoMyUsbongVariableMemory("surname", prefs.getString("surname", ""));//"" is the default value.
             setVariableOntoMyUsbongVariableMemory("contactNumber", prefs.getString("contactNumber", ""));//"" is the default value.
             setVariableOntoMyUsbongVariableMemory("shippingAddress", prefs.getString("shippingAddress", ""));//"" is the default value.
            }
            else {
              setVariableOntoMyUsbongVariableMemory("firstName", "");//"" is the default value.
              setVariableOntoMyUsbongVariableMemory("surname", "");//"" is the default value.
              setVariableOntoMyUsbongVariableMemory("contactNumber", "");//"" is the default value.
              setVariableOntoMyUsbongVariableMemory("shippingAddress", "");//"" is the default value.           
            }        
    */
    //added by Mike, March 26, 2014
    try {
        Log.d(">>>>", "" + UsbongUtils.STORE_OUTPUT);
        if (UsbongUtils.STORE_OUTPUT) { //added by Mike, 27 Sept. 2015
            UsbongUtils.createNewOutputFolderStructure();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    /*        
    //       initTreeLoader();
          //added by JPT, May 25, 2015
          if(getIntent().getStringExtra(Constants.UTREE_KEY) != null) {
             Log.d("DecisionTree", getIntent().getStringExtra(Constants.UTREE_KEY));
             initParser(getIntent().getStringExtra(Constants.UTREE_KEY));
          } else {         
              initTreeLoader();
          }
          */
    /*       initTreeLoader(); //not needed in Usbong Kuto, Mike, 25 Sept 2015
     */
    //added by Mike, 30 April 2015
    isInTreeLoader = false;

    //added by Mike, 20160119
    if (getIntent().getStringExtra("utreeToLoad") != null) {
        myTree = getIntent().getStringExtra("utreeToLoad");
    } else {
        myTree = UsbongUtils.DEFAULT_UTREE_TO_LOAD; //edited by Mike, 20160418
    }

    UsbongUtils.clearTempFolder();
    //            isr=null; //set inputStreamReader to null; i.e. new tree
    /*              initParser();   
    */

    //              myProgressDialog.dismiss();
    /*              
      //added by Mike, 29 Sept. 2015
      //Reference: http://stackoverflow.com/questions/10407159/how-to-manage-startactivityforresult-on-android;
      //last accessed: 29 Sept. 2015; answer by Nishant, 2 May 2012; edited by Daniel Nugent, 9 July 2015
      Intent returnIntent = new Intent();
      returnIntent.putExtra("result","result");
      setResult(RESULT_OK,returnIntent);
    */
}