Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7890987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:30:01+00:00 2026-06-03T06:30:01+00:00

I want to know how to keep the app from reloading when the orientation

  • 0

I want to know how to keep the app from reloading when the orientation is changed?

I have a small test app that will play an audio sound until the stop button is pressed. If I change my Android or the simulator from horizontal to portrait then the stop button does not work. A second occurrence of the app is loaded. I want the first occurrence to keep running regardless if the orientation has been changed.

Main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:layout_height="fill_parent" android:orientation="horizontal">


<LinearLayout

android:layout_width="wrap_content"

android:layout_height="match_parent"

android:layout_weight="0.64" android:orientation="horizontal">


<Button

android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Play" />


<Button

android:id="@+id/button2"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Stop" />


</LinearLayout>


</LinearLayout>

Test.java

import android.app.Activity;

import android.media.AudioManager;

import android.media.MediaPlayer;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;


public class TestAppActivity extends Activity {

private Button btnDisplay;

private MediaPlayer mediaPlayer;


@Override

public void onCreate(Bundle savedInstanceState) 

{

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

setVolumeControlStream(AudioManager.STREAM_MUSIC);

mediaPlayer = MediaPlayer.create(this, R.raw.nut);

mediaPlayer.setLooping(true);


((Button)findViewById(R.id.button1)).setOnClickListener( new View.OnClickListener() {


public void onClick(View v) {

mediaPlayer = MediaPlayer.create(LoopBugActivity.this, R.raw.nut);

mediaPlayer.setLooping(true);

mediaPlayer.start(); 

}

} );



((Button)findViewById(R.id.button2)).setOnClickListener( new View.OnClickListener() {


public void onClick(View v) {

mediaPlayer.stop();

}

} );

}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:30:03+00:00Added an answer on June 3, 2026 at 6:30 am

    I added to the manifest:
    android:screenOrientation=”landscape”
    android:configChanges=”keyboardHidden|orientation”

    and to the Activity Java file.

    @Override public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);     
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
        } 
    

    The layout stays in Landscape and rotation of the orientation does not affect the playing of the app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know what this looks like. I don't have any ideas about
I have some processing in my Cocoa app that sometimes ends up calling through
I am creating a new settings screen for my app and want to keep
I currently am working on a little app that requests user info from my
I have a request for some contract work from an organization that uses Excel
I want to have one table with two TIMESTAMP columns. One column to keep
I have an existing app that has many, many models. I'd like to log
We have a SaaS web app and are looking to get some feedback from
I have an app which I want to open, use, and then at the
Scenario: I have a Grails app that uses Acegi security for authentication. I'm implementing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.