[android-developers] I can't get Speaker Phone to work on my App

2016-11-18 Thread Timothy Hopfer
No matter what combination I have tried, I do not seem to be able to get 
the speakerphone to turn on and play out the speakers like it is supposed 
to.  I have headphones plugged in for testing, but the app does not seem to 
play out of my HTC 626.  The frustrating part is that it works on my HTC 
Desire Eye perfectly, but not the HTC Desire 626.  I heard the issue was a 
matter of model, but I cant seem to make it work at all for my HTC 626.  
Does anyone know have any idea of what I can do to fix this problem?  
Please help!!!

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/2cc37523-9f68-478e-98b4-7ad50a943be7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] App works fine on Kitkat, but does not work on Lollypop

2016-11-17 Thread Timothy Hopfer
It doesn't show any errors, that's why I am confused, it does say skipped
one media player item...but throws no exceptions...just doesn't act right

On Thu, Nov 17, 2016 at 12:28 PM sardar khan 
wrote:

> kindly post the logcat error here.
>
> On Thu, Nov 17, 2016 at 9:51 PM, Timothy Hopfer 
> wrote:
>
> I made an app that tests the speakers in an HTC phone.  it tests both the
> bottom speaker, the top speaker, and the headphones, all while the
> headphones are plugged in.  It works perfectly in the HTC Desire Eye that
> is running KitKat 4.4.4, but it does not work correctly on the HTC Desire
> that is running Lollypop 5.1.  In the lollypop phone, it only plays from
> the bottom speaker, and if the headphones are plugged in, it goes through
> the headphones instead.  I have been looking everywhere but cant find the
> answer.  Does anyone know what I should do to make my app work in
> Lollypop?  I have included the code in case you see some deprecated code
> that I should update.  Also, the app does not crash on Lollypop, just does
> the audiomanager or mediaplayer doesn't work the correctly.  Thanks so much.
>
> public class LeftSpeakerActivity extends Activity {
> int default_mode; //Saves the default mode of the device
> int music_volume; //Saves the default volume of the music stream
> int call_volume; //Saves the default volume of the in call stream
> String device_type = null;//Stores the device type
> AudioManager audioManager; //Object to provide access to system
> volume controls and settings
> String model = android.os.Build.MODEL;
> String Manufacturer = android.os.Build.MANUFACTURER;
> boolean isNexus = false;
> TextView title_text;
> MediaPlayer mp;
> //preset volume
> int volume = 10;
> public final static String log_tag = "LeftSpeaker";
>
> Handler mHandler = new Handler();
> /*
> * (non-Javadoc)
> * @see android.app.Activity#onCreate(android.os.Bundle).
> * First function entered when the application is created
> * This function is used to initialize the layout and the device
> type
> * based on the model and device Manufacturer.This function also
> stores
> * the default audio stream value and modes to reset it back to
> these
> * values once we exit the application
> */
> @Override
> protected void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
>
> /*
>  * API's to launch the application when the tablet is locked or
>  * display is turned off
>  */
>
> getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
>
> getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
>
> getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
> //
> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
>
> setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
> setContentView(R.layout.activity_left_speaker);
>
>
> title_text = ((TextView) findViewById(R.id.textView3));
> title_text.setTextColor(Color.RED);
> title_text.setText("LEFT SPEAKER TEST IN PROGRESS" + "\n" +
> "VOLUME IS SET AT" + volume);
> Context mContext = getApplicationContext();
> createTempFile("Status_LeftSpeaker.txt", "INPROGRESS");
>
> audioManager = (AudioManager)
> getSystemService(Context.AUDIO_SERVICE);
> default_mode = audioManager.getMode();
> music_volume =
> audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
> call_volume =
> audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
>
> //Setting the volume level
> audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume,
> AudioManager.FLAG_SHOW_UI);
> audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL,
> volume, AudioManager.FLAG_SHOW_UI);
> audioManager.setSpeakerphoneOn(true);
>
> //start_playing();
> playSound(true);
>
> }
> //TRUE PLAYS OVER SPEAKERS
> private void playSound(boolean speakers){
>
> mp = MediaPlayer.create(getApplicationContext(),
> R.raw.tone_right);
> if (speakers){
> mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
>
> }else {
> mp.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
>
>  

[android-developers] App works fine on Kitkat, but does not work on Lollypop

2016-11-17 Thread Timothy Hopfer
I made an app that tests the speakers in an HTC phone.  it tests both the 
bottom speaker, the top speaker, and the headphones, all while the 
headphones are plugged in.  It works perfectly in the HTC Desire Eye that 
is running KitKat 4.4.4, but it does not work correctly on the HTC Desire 
that is running Lollypop 5.1.  In the lollypop phone, it only plays from 
the bottom speaker, and if the headphones are plugged in, it goes through 
the headphones instead.  I have been looking everywhere but cant find the 
answer.  Does anyone know what I should do to make my app work in 
Lollypop?  I have included the code in case you see some deprecated code 
that I should update.  Also, the app does not crash on Lollypop, just does 
the audiomanager or mediaplayer doesn't work the correctly.  Thanks so much.

public class LeftSpeakerActivity extends Activity {
int default_mode; //Saves the default mode of the device
int music_volume; //Saves the default volume of the music stream
int call_volume; //Saves the default volume of the in call stream
String device_type = null;//Stores the device type
AudioManager audioManager; //Object to provide access to system 
volume controls and settings
String model = android.os.Build.MODEL;
String Manufacturer = android.os.Build.MANUFACTURER;
boolean isNexus = false;
TextView title_text;
MediaPlayer mp;
//preset volume
int volume = 10;
public final static String log_tag = "LeftSpeaker";

Handler mHandler = new Handler();
/*
* (non-Javadoc)
* @see android.app.Activity#onCreate(android.os.Bundle).
* First function entered when the application is created
* This function is used to initialize the layout and the device type
* based on the model and device Manufacturer.This function also 
stores
* the default audio stream value and modes to reset it back to these
* values once we exit the application
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

/*
 * API's to launch the application when the tablet is locked or
 * display is turned off
 */

getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
//
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
setContentView(R.layout.activity_left_speaker);


title_text = ((TextView) findViewById(R.id.textView3));
title_text.setTextColor(Color.RED);
title_text.setText("LEFT SPEAKER TEST IN PROGRESS" + "\n" + 
"VOLUME IS SET AT" + volume);
Context mContext = getApplicationContext();
createTempFile("Status_LeftSpeaker.txt", "INPROGRESS");

audioManager = (AudioManager) 
getSystemService(Context.AUDIO_SERVICE);
default_mode = audioManager.getMode();
music_volume = 
audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
call_volume = 
audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);

//Setting the volume level
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,volume, 
AudioManager.FLAG_SHOW_UI);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 
volume, AudioManager.FLAG_SHOW_UI);
audioManager.setSpeakerphoneOn(true);

//start_playing();
playSound(true);

}
//TRUE PLAYS OVER SPEAKERS
private void playSound(boolean speakers){

mp = MediaPlayer.create(getApplicationContext(), 
R.raw.tone_right);
if (speakers){
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);

}else {
mp.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);

}
mp.start();
mp.setOnCompletionListener(new 
MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
createTempFile("Status_LeftSpeaker.txt", "COMPLETED");
exit_function();
}
});
}


private void exit_function() {
onDestroy();
}

@Override
/*
 * (non-Javadoc)
 * @see android.app.Activity#onDestroy()
 * Function invoked before we exit the application . Reset all the 
volume
 * and stream values in this function
 */
protected void onDestroy() {
Log.i(log_tag,"Entered onDestroy()");