Example usage for android.media AudioManager setStreamVolume

List of usage examples for android.media AudioManager setStreamVolume

Introduction

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

Prototype

public void setStreamVolume(int streamType, int index, int flags) 

Source Link

Document

Sets the volume index for a particular stream.

Usage

From source file:com.PPRZonDroid.MainActivity.java

/**
 * Play warning sound if airspeed goes below the selected value
 *
 * @param context// w  ww  . j  a v  a  2s.com
 * @throws IllegalArgumentException
 * @throws SecurityException
 * @throws IllegalStateException
 * @throws IOException
 */
public void play_sound(Context context)
        throws IllegalArgumentException, SecurityException, IllegalStateException, IOException {

    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    MediaPlayer mMediaPlayer = new MediaPlayer();
    mMediaPlayer.setDataSource(context, soundUri);
    final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    //Set volume max!!!
    audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM,
            audioManager.getStreamMaxVolume(audioManager.STREAM_SYSTEM), 0);

    if (audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM) != 0) {
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_SYSTEM);
        mMediaPlayer.setLooping(true);
        mMediaPlayer.prepare();
        mMediaPlayer.start();
    }
}

From source file:org.botlibre.sdk.activity.ChatActivity.java

private void muteMicBeep(boolean mute) {
    debug("muteMicBeep:" + mute + ":" + MainActivity.volume);
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    if (mute) {//from  ww w  .j ava  2 s . c o  m
        //if its true then the Volume will be zero.
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, 0);
    } else {
        //if its false, the Volume will put back on
        audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, MainActivity.volume, 0);
    }
}

From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java

protected void setVolume(int newVolume) {
    AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    audio.setStreamVolume(AudioManager.STREAM_MUSIC, newVolume, 0);
    if (LOCAL_LOGV)
        log("volume set:" + String.valueOf(audio.getStreamVolume(AudioManager.STREAM_MUSIC)), "v");
}

From source file:com.metinkale.prayerapp.vakit.AlarmReceiver.java

public void fireAlarm(Intent intent) throws InterruptedException {

    Context c = App.getContext();

    if ((intent == null) || !intent.hasExtra("json")) {

        return;//from   w w w  . ja  v a 2  s  .c om
    }
    Alarm next = Alarm.fromString(intent.getStringExtra("json"));
    intent.removeExtra("json");

    if (next.city == 0) {
        return;
    }

    Times t = Times.getTimes(next.city);
    if (t == null)
        return;
    boolean active;
    if (next.cuma) {
        active = t.isCumaActive();
    } else if (next.early) {
        active = t.isEarlyNotificationActive(next.vakit);
    } else {
        active = t.isNotificationActive(next.vakit);
    }
    if (!active) {
        return;
    }

    boolean vibrate;
    String sound;
    String dua;
    long silenter;
    if (next.cuma) {
        vibrate = t.hasCumaVibration();
        sound = t.getCumaSound();
        dua = "silent";
        silenter = t.getCumaSilenterDuration();
    } else if (next.early) {
        vibrate = t.hasEarlyVibration(next.vakit);
        sound = t.getEarlySound(next.vakit);
        dua = "silent";
        silenter = t.getEarlySilenterDuration(next.vakit);
    } else {
        vibrate = t.hasVibration(next.vakit);
        sound = t.getSound(next.vakit);
        dua = t.getDua(next.vakit);
        silenter = t.getSilenterDuration(next.vakit);
    }

    NotificationManager nm = (NotificationManager) c.getSystemService(Context.NOTIFICATION_SERVICE);

    nm.cancel(next.city + "", NotIds.ALARM);
    String text;

    text = t.getName() + " (" + t.getSource() + ")";

    String txt = "";
    if (next.early) {
        String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part);
        txt = App.getContext().getString(R.string.earlyText, left_part[next.vakit.index],
                "" + t.getEarlyTime(next.vakit));
    } else if (next.cuma) {
        String[] left_part = App.getContext().getResources().getStringArray(R.array.lefttext_part);
        txt = App.getContext().getString(R.string.earlyText, left_part[next.vakit.index], "" + t.getCumaTime());
    } else if (next.vakit != null) {
        txt = next.vakit.getString();
    }

    NotificationCompat.Builder builder = new NotificationCompat.Builder(c).setContentTitle(text)
            .setContentText(txt).setContentIntent(Main.getPendingIntent(t)).setSmallIcon(R.drawable.ic_abicon);
    Notification not = builder.build();

    if (vibrate) {
        not.vibrate = VibrationPreference.getPattern(c, "vibration");
    }

    AudioManager am = (AudioManager) c.getSystemService(Context.AUDIO_SERVICE);

    class MPHolder {
        MediaPlayer mp;
    }
    not.deleteIntent = PendingIntent.getBroadcast(c, 0, new Intent(c, Audio.class),
            PendingIntent.FLAG_UPDATE_CURRENT);

    nm.notify(next.city + "", NotIds.ALARM, not);

    final MPHolder mp = new MPHolder();

    if (Prefs.showNotificationScreen() && (sound != null) && !sound.startsWith("silent")) {
        PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        if (!pm.isScreenOn()) {
            Intent i = new Intent(c, NotificationPopup.class);
            i.putExtra("city", next.city);
            i.putExtra("name", text);
            i.putExtra("vakit", txt);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
            c.startActivity(i);

            Thread.sleep(1000);
        }
    }

    sInterrupt = false;
    boolean hasSound = false;
    while ((sound != null) && !sound.startsWith("silent") && !sInterrupt) {
        int volume = -2;
        hasSound = true;

        if (!sound.startsWith("silent") && !sound.startsWith("picker")) {

            if (sound.contains("$volume")) {
                volume = Integer.parseInt(sound.substring(sound.indexOf("$volume") + 7));
                sound = sound.substring(0, sound.indexOf("$volume"));
            }
            if (volume != -2) {
                int oldvalue = am.getStreamVolume(getStreamType(c));
                am.setStreamVolume(getStreamType(c), volume, 0);
                volume = oldvalue;
            }

            try {
                mp.mp = play(c, sound);
            } catch (IOException e) {
                e.printStackTrace();
                if (next.cuma) {
                    t.setCumaSound("silent");
                } else if (next.early) {
                    t.setEarlySound(next.vakit, "silent");
                } else {
                    if ("sound".equals(t.getSound(next.vakit))) {
                        t.setSound(next.vakit, "silent");
                    } else {
                        t.setDua(next.vakit, "silent");
                    }
                }
                mp.mp = null;
            }

            if (mp.mp != null) {

                mp.mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                    @Override
                    public void onCompletion(MediaPlayer mediaPlayer) {
                        if (mp.mp == null) {
                            return;
                        }
                        mp.mp.stop();
                        mp.mp.release();
                        mp.mp = null;
                    }
                });

                mp.mp.setOnSeekCompleteListener(new MediaPlayer.OnSeekCompleteListener() {
                    @Override
                    public void onSeekComplete(MediaPlayer mediaPlayer) {
                        if (mp.mp == null) {
                            return;
                        }
                        mp.mp.stop();
                        mp.mp.release();
                        mp.mp = null;
                    }
                });

            }

            sInterrupt = false;

            while ((mp.mp != null) && mp.mp.isPlaying()) {
                if (sInterrupt) {
                    mp.mp.stop();
                    mp.mp.release();
                    mp.mp = null;

                    dua = null;
                } else {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException ignore) {
                    }
                }
            }
            sInterrupt = false;

        }

        if (volume != -2) {
            am.setStreamVolume(getStreamType(c), volume, 0);
        }
        sound = dua;
        dua = null;
    }

    if (hasSound && Prefs.autoRemoveNotification()) {
        nm.cancel(next.city + "", NotIds.ALARM);
    }
    if (silenter != 0) {
        silenter(c, silenter);
    }

}

From source file:org.drrickorang.loopback.LoopbackActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set the layout for this activity. You can find it
    View view = getLayoutInflater().inflate(R.layout.main_activity, null);
    setContentView(view);/*w ww  .j a  v a2s .c  o  m*/

    mTextInfo = (TextView) findViewById(R.id.textInfo);
    mBarMasterLevel = (SeekBar) findViewById(R.id.BarMasterLevel);

    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int maxVolume = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    mBarMasterLevel.setMax(maxVolume);

    mBarMasterLevel.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
            am.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0);
            refreshState();
            log("Changed stream volume to: " + progress);
        }
    });
    mWavePlotView = (WavePlotView) findViewById(R.id.viewWavePlot);

    mTextViewCurrentLevel = (TextView) findViewById(R.id.textViewCurrentLevel);
    mTextViewCurrentLevel.setTextSize(15);

    mTextViewEstimatedLatency = (TextView) findViewById(R.id.textViewEstimatedLatency);
    refreshState();

    applyIntent(getIntent());
}

From source file:usbong.android.likha_collection_1.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"));
    }/*from   w  ww.j  av a  2 s  .co  m*/

    //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, 20161111
        UsbongUtils.storeAssetsFileIntoSDCard(this, "pagtsing.utree");
        UsbongUtils.storeAssetsFileIntoSDCard(this, "gamugamo.utree");
        UsbongUtils.storeAssetsFileIntoSDCard(this, "juant.utree");

        UsbongUtils.storeAssetsFileIntoSDCard(this, "pagtsing_icon.png");
        UsbongUtils.storeAssetsFileIntoSDCard(this, "gamugamo_icon.png");
        UsbongUtils.storeAssetsFileIntoSDCard(this, "juant_icon.png");
    } 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>();

    //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();
    }
    /*//commented out by Mike, 20161110      
          //added by Mike, 30 April 2015
          isInTreeLoader=false;      
          myTree = UsbongUtils.DEFAULT_UTREE_TO_LOAD; //edited by Mike, 20160418
          UsbongUtils.clearTempFolder();
    */
    initTreeLoader();
}

From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java

private void setDefaultPrefs(Map<String, String> DbPrefs) {
    String valueTmp = "";
    mVoltageAlarm = getDouble(mVoltageAlarm, DbPrefs.get("mVoltageAlarm"));
    mUsedCap = getDouble(mUsedCap, DbPrefs.get("mUsedCap"));
    mCurrentAlarm = getDouble(mCurrentAlarm, DbPrefs.get("mCurrentAlarm"));
    mPowerAlarm = getDouble(mPowerAlarm, DbPrefs.get("mPowerAlarm"));

    mSpeedAlarm = getInteger(mSpeedAlarm, DbPrefs.get("mSpeedAlarm"));
    mRpmAlarm = getInteger(mRpmAlarm, DbPrefs.get("mRpmAlarm"));
    mAltitudeAlarm = getInteger(mAltitudeAlarm, DbPrefs.get("mAltitudeAlarm"));
    mFuelAlarm = getInteger(mFuelAlarm, DbPrefs.get("mFuelAlarm"));
    voltage_hysteresis = getInteger(voltage_hysteresis, DbPrefs.get("voltage_hysteresis"));
    current_hysteresis = getInteger(current_hysteresis, DbPrefs.get("current_hysteresis"));
    rpm_hysteresis = getInteger(rpm_hysteresis, DbPrefs.get("rpm_hysteresis"));
    temperature_hysteresis = getInteger(temperature_hysteresis, DbPrefs.get("temperature_hysteresis"));
    power_hysteresis = getInteger(power_hysteresis, DbPrefs.get(""));
    mTemperatureAlarm = getInteger(mTemperatureAlarm, DbPrefs.get("power_hysteresis"));
    speech_volume = getInteger(speech_volume, DbPrefs.get("speech_volume"));
    AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int sb2value = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    sb2value = sb2value * speech_volume / 100;
    am.setStreamVolume(AudioManager.STREAM_MUSIC, sb2value, 0);
    vibrate_on = getBoolean(vibrate_on, DbPrefs.get("vibrate_on"));
    voltage_speech_ack = getBoolean(voltage_speech_ack, DbPrefs.get("voltage_speech_ack"));
    current_speech_ack = getBoolean(current_speech_ack, DbPrefs.get("current_speech_ack"));
    height_speech_ack = getBoolean(height_speech_ack, DbPrefs.get("height_speech_ack"));
    used_speech_ack = getBoolean(used_speech_ack, DbPrefs.get("used_speech_ack"));
    speed_speech_ack = getBoolean(speed_speech_ack, DbPrefs.get("speed_speech_ack"));
    rpm_speech_ack = getBoolean(rpm_speech_ack, DbPrefs.get("rpm_speech_ack"));
    temp_speech_ack = getBoolean(temp_speech_ack, DbPrefs.get("temp_speech_ack"));

    voltage_speech_label = DbPrefs.get("voltage_speech_label");
    voltage_speech_unit = DbPrefs.get("voltage_speech_unit");

    height_speech_label = DbPrefs.get("height_speech_label");
    height_speech_unit = DbPrefs.get("height_speech_unit");

    current_speech_label = DbPrefs.get("current_speech_label");
    current_speech_unit = DbPrefs.get("current_speech_unit");

    used_speech_label = DbPrefs.get("used_speech_label");
    used_speech_unit = DbPrefs.get("used_speech_unit");

    speed_speech_label = DbPrefs.get("speed_speech_label");
    speed_speech_unit = DbPrefs.get("speed_speech_unit");

    rpm_speech_label = DbPrefs.get("rpm_speech_label");
    rpm_speech_unit = DbPrefs.get("rpm_speech_unit");

    temp_speech_label = DbPrefs.get("temp_speech_label");
    temp_speech_unit = DbPrefs.get("temp_speech_unit");

    valueTmp = DbPrefs.get("log_file");
    if (valueTmp != "") {
        log_file = valueTmp;/*from   ww  w .  ja  va 2s.com*/
    }

    valueTmp = DbPrefs.get("bluetooth_device");
    if (valueTmp != "") {
        bluetooth_device = valueTmp;
    }
    mSound_on = getBoolean(mSound_on, DbPrefs.get("mSound_on"));
    speech_on = getBoolean(speech_on, DbPrefs.get("speech_on"));
    speech_intervall = DbPrefs.get("speech_intervall");
    mAlarm_on = getBoolean(mAlarm_on, DbPrefs.get("mAlarm_on"));
    mlog_file = getBoolean(mlog_file, DbPrefs.get("mlog_file"));
    alert_tone = DbPrefs.get("alert_tone");
    label_rpm1 = DbPrefs.get("label_rpm1");
    label_rpm2 = DbPrefs.get("label_rpm2");
    label_temp1 = DbPrefs.get("label_temp1");
    label_temp2 = DbPrefs.get("label_temp2");
    unit_rpm1 = DbPrefs.get("unit_rpm1");
    unit_rpm2 = DbPrefs.get("unit_rpm2");
    unit_temp1 = DbPrefs.get("unit_temp1");
    unit_temp2 = DbPrefs.get("unit_temp2");
    current_sensor_type = DbPrefs.get("current_sensor_type");
    alarm_voltage = getBoolean(alarm_voltage, DbPrefs.get("alarm_voltage"));
    alarm_used = getBoolean(alarm_used, DbPrefs.get("alarm_used"));
    alarm_current = getBoolean(alarm_current, DbPrefs.get("alarm_current"));
    alarm_speed = getBoolean(alarm_speed, DbPrefs.get("alarm_speed"));
    alarm_fuel = getBoolean(alarm_fuel, DbPrefs.get("alarm_fuel"));
    alarm_temperature = getBoolean(alarm_temperature, DbPrefs.get("alarm_temperature"));
    alarm_altitude = getBoolean(alarm_altitude, DbPrefs.get("alarm_altitude"));
    alarm_rpm = getBoolean(alarm_rpm, DbPrefs.get("alarm_rpm"));
    alarm_power = getBoolean(alarm_power, DbPrefs.get("alarm_power"));

    if (rpm1Label != null)
        rpm1Label.setText(label_rpm1);
    if (rpm2Label != null)
        rpm2Label.setText(label_rpm2);
    if (tempLabel != null)
        tempLabel.setText(label_temp1);
    if (temp2Label != null)
        temp2Label.setText(label_temp2);

    if (rpm1_unit != null)
        rpm1_unit.setText(unit_rpm1);
    if (rpm2_unit != null)
        rpm2_unit.setText(unit_rpm2);
    if (temp1_unit != null)
        temp1_unit.setText(unit_temp1);
    if (temp1_unit != null)
        temp1_unit.setText(unit_temp2);

    if (alert_tone.equals("")) {
        uri = null;
    } else {
        uri = Uri.parse(alert_tone);
    }

    if (mp != null) {
        mp.stop();
        mp.release();
        mp = null;
        if (uri != null && !uri.toString().equals("res/raw/alarm.mp3")) {
            mp = MediaPlayer.create(getApplicationContext(), uri);
        } else {
            mp = MediaPlayer.create(getApplicationContext(), R.raw.alarm);
        }
    }
}

From source file:de.rosche.spectraTelemetry.SpectraTelemetry.java

public void readPrefs() {
    String valueTmp = "";
    try {/*  w w  w.j a va 2 s  . c o  m*/
        voltage_speech_alert = mPrefs.getString("voltage_speech_alert", voltage_speech_alert);
        height_speech_alert = mPrefs.getString("height_speech_alert", height_speech_alert);
        current_speech_alert = mPrefs.getString("current_speech_alert", current_speech_alert);
        used_speech_alert = mPrefs.getString("used_speech_alert", used_speech_alert);
        temp_speech_alert = mPrefs.getString("temp_speech_alert", temp_speech_alert);
        rpm_speech_alert = mPrefs.getString("rpm_speech_alert", rpm_speech_alert);
        speed_speech_alert = mPrefs.getString("speed_speech_alert", speed_speech_alert);
        mVoltageAlarm = getDouble("voltage", mVoltageAlarm);
        mUsedCap = getDouble("used_cap", mUsedCap);
        mCurrentAlarm = getDouble("current", mCurrentAlarm);
        mPowerAlarm = getDouble("power", mPowerAlarm);
        mSpeedAlarm = tools.getInteger("speed", mSpeedAlarm, mPrefs);
        // mSpeedAlarm = getInteger("speed", mSpeedAlarm);
        mRpmAlarm = getInteger("rpm", mRpmAlarm);
        mAltitudeAlarm = getInteger("altitude", mAltitudeAlarm);
        mFuelAlarm = getInteger("fuel", mFuelAlarm);
        voltage_hysteresis = getInteger("voltage_hysteresis", voltage_hysteresis);
        current_hysteresis = getInteger("current_hysteresis", current_hysteresis);
        rpm_hysteresis = getInteger("rpm_hysteresis", rpm_hysteresis);
        temperature_hysteresis = getInteger("temperature_hysteresis", temperature_hysteresis);

        power_hysteresis = getInteger("power_hysteresis", power_hysteresis);
        mTemperatureAlarm = getInteger("temperature", mTemperatureAlarm);
        speech_volume = getInteger("speech_volume", speech_volume);
        AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
        int sb2value = am.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
        sb2value = sb2value * speech_volume / 100;
        am.setStreamVolume(AudioManager.STREAM_MUSIC, sb2value, 0);
        vibrate_on = mPrefs.getBoolean("vibrate_on", vibrate_on);
        metric = mPrefs.getBoolean("metric", metric);
        mpxData = mPrefs.getBoolean("mpx_data", mpxData);
        displayAlwaysOn = mPrefs.getBoolean("displayAlwaysOn", displayAlwaysOn);
        voltage_speech_ack = mPrefs.getBoolean("voltage_speech_ack", voltage_speech_ack);
        valueTmp = voltage_speech_label + ";" + voltage_speech_unit;
        valueTmp = mPrefs.getString("voltage_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            voltage_speech_label = tokens.nextToken().trim();
            voltage_speech_unit = tokens.nextToken().trim();
        }

        height_speech_ack = mPrefs.getBoolean("height_speech_ack", height_speech_ack);
        auto_connect = mPrefs.getBoolean("auto_connect", auto_connect);
        mpxData = mPrefs.getBoolean("mpx_data", mpxData);
        valueTmp = height_speech_label + ";" + height_speech_unit;
        valueTmp = mPrefs.getString("height_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            height_speech_label = tokens.nextToken().trim();
            height_speech_unit = tokens.nextToken().trim();
        }
        current_speech_ack = mPrefs.getBoolean("current_speech_ack", current_speech_ack);
        valueTmp = current_speech_label + ";" + current_speech_unit;
        valueTmp = mPrefs.getString("current_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            current_speech_label = tokens.nextToken().trim();
            current_speech_unit = tokens.nextToken().trim();
        }
        used_speech_ack = mPrefs.getBoolean("used_speech_ack", used_speech_ack);
        valueTmp = used_speech_label + ";" + used_speech_unit;
        valueTmp = mPrefs.getString("used_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            used_speech_label = tokens.nextToken().trim();
            used_speech_unit = tokens.nextToken().trim();
        }
        speed_speech_ack = mPrefs.getBoolean("speed_speech_ack", speed_speech_ack);
        valueTmp = speed_speech_label + ";" + speed_speech_unit;
        valueTmp = mPrefs.getString("speed_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            speed_speech_label = tokens.nextToken().trim();
            speed_speech_unit = tokens.nextToken().trim();
        }
        vario_delay = mPrefs.getString("vario_delay", vario_delay);
        rpm_speech_ack = mPrefs.getBoolean("rpm_speech_ack", rpm_speech_ack);
        valueTmp = rpm_speech_label + ";" + rpm_speech_unit;
        valueTmp = mPrefs.getString("rpm_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            rpm_speech_label = tokens.nextToken().trim();
            rpm_speech_unit = tokens.nextToken().trim();
        }

        temp_speech_ack = mPrefs.getBoolean("temp_speech_ack", temp_speech_ack);
        valueTmp = temp_speech_label + ";" + temp_speech_unit;
        valueTmp = mPrefs.getString("temp_speech_text", valueTmp);
        if (!valueTmp.equals("") && valueTmp.contains(";")) {
            StringTokenizer tokens = new StringTokenizer(valueTmp, ";");
            temp_speech_label = tokens.nextToken().trim();
            temp_speech_unit = tokens.nextToken().trim();
        }

    } catch (Exception e) {
    }
    valueTmp = mPrefs.getString("log_file", log_file);
    if (valueTmp != "") {
        log_file = valueTmp;
    }
    valueTmp = mPrefs.getString("bluetooth_device", bluetooth_device);
    if (valueTmp != "") {
        bluetooth_device = valueTmp;
    }
    mSound_on = mPrefs.getBoolean("sound_on", mSound_on);
    speech_on = mPrefs.getBoolean("speech_on", speech_on);
    speech_intervall = mPrefs.getString("speech_intervall", speech_intervall);

    speech_alert_intervall = mPrefs.getString("speech_alert_intervall", speech_alert_intervall);
    mAlarm_on = mPrefs.getBoolean("alarm_on", mAlarm_on);
    mSpeak_on = mPrefs.getBoolean("speak_on", mSpeak_on);
    mlog_file = mPrefs.getBoolean("logging_on", mlog_file);
    alert_tone = mPrefs.getString("ringtone", alert_tone);
    label_rpm1 = mPrefs.getString("label_rpm1", label_rpm1);
    label_rpm2 = mPrefs.getString("label_rpm2", label_rpm2);
    label_temp1 = mPrefs.getString("label_temp1", label_temp1);
    label_temp2 = mPrefs.getString("label_temp2", label_temp2);
    unit_rpm1 = mPrefs.getString("unit_rpm1", unit_rpm1);
    unit_rpm2 = mPrefs.getString("unit_rpm2", unit_rpm2);
    unit_temp1 = mPrefs.getString("unit_temp1", unit_temp1);
    unit_temp2 = mPrefs.getString("unit_temp2", unit_temp2);
    current_sensor_type = mPrefs.getString("current_sensor_type", current_sensor_type);
    vario_delay = mPrefs.getString("vario_delay", vario_delay);

    alarm_voltage = mPrefs.getBoolean("alarm_voltage", alarm_voltage);
    alarm_used = mPrefs.getBoolean("alarm_used", alarm_used);
    alarm_current = mPrefs.getBoolean("alarm_current", alarm_current);
    alarm_speed = mPrefs.getBoolean("alarm_speed", alarm_speed);
    alarm_fuel = mPrefs.getBoolean("alarm_fuel", alarm_fuel);
    alarm_temperature = mPrefs.getBoolean("alarm_temperature", alarm_temperature);
    alarm_altitude = mPrefs.getBoolean("alarm_altitude", alarm_altitude);
    alarm_rpm = mPrefs.getBoolean("alarm_rpm", alarm_rpm);
    alarm_power = mPrefs.getBoolean("alarm_power", alarm_power);
    speak_voltage = mPrefs.getBoolean("speak_voltage", speak_voltage);
    speak_used = mPrefs.getBoolean("speak_used", speak_used);
    speak_current = mPrefs.getBoolean("speak_current", speak_current);
    speak_speed = mPrefs.getBoolean("speak_speed", speak_speed);
    speak_fuel = mPrefs.getBoolean("speak_fuel", speak_fuel);
    speak_temperature = mPrefs.getBoolean("speak_temperature", speak_temperature);
    speak_altitude = mPrefs.getBoolean("speak_altitude", speak_altitude);
    speak_rpm = mPrefs.getBoolean("speak_rpm", speak_rpm);
    speak_power = mPrefs.getBoolean("speak_power", speak_power);
    if (rpm1Label != null)
        rpm1Label.setText(label_rpm1);
    if (rpm2Label != null)
        rpm2Label.setText(label_rpm2);
    if (tempLabel != null)
        tempLabel.setText(label_temp1);
    if (temp2Label != null)
        temp2Label.setText(label_temp2);
    if (rpm1_unit != null)
        rpm1_unit.setText(unit_rpm1);
    if (rpm2_unit != null)
        rpm2_unit.setText(unit_rpm2);
    if (temp1_unit != null)
        temp1_unit.setText(unit_temp1);
    if (temp1_unit != null)
        temp1_unit.setText(unit_temp2);
    if (alert_tone.equals("")) {
        uri = null;
    } else {
        uri = Uri.parse(alert_tone);
    }
    if (mp != null) {
        mp.stop();
        mp.release();
        mp = null;
        if (uri != null && !uri.toString().equals("res/raw/alarm.mp3")) {

            mp = MediaPlayer.create(getApplicationContext(), uri);
        } else {
            mp = MediaPlayer.create(getApplicationContext(), R.raw.alarm);
        }
    }
}

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"));
    }//from   w  w  w  . java 2 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);
    */
}