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);
>
> }
> mp.start();
> mp.setOnCompletionListener(new
> MediaPlayer.OnCompletionListener() {
> @Override
> public void onCompletion(MediaPlayer mp) {
> createTempFile("Status_LeftSpeaker.txt", "COMPLETED");
> exit_function();
> }
>

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

2016-11-17 Thread sardar khan
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);
>
> }
> 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)
>