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 6758351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:46:33+00:00 2026-05-26T13:46:33+00:00

In my application, I have an activity play http live streaming video in landscape

  • 0

In my application, I have an activity play http live streaming video in landscape mode.

My AndroidManifest.xml:

<activity android:name=".MediaPlayerActivity"
    android:label="@string/menu_player"
    android:launchMode="singleInstance"
    android:screenOrientation="landscape">
</activity>

My activity layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
  android:orientation="vertical"
  android:layout_width="fill_parent" 
  android:layout_height="fill_parent"
  android:background="@color/black">

  <VideoView android:id="@+id/myVideoView"
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent" 
    android:layout_gravity="center_horizontal" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentRight="true" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true"/>

</LinearLayout>

The problem is everytime I close this activity (By clicking back button), it always rotate to portrait mode (time is very soon but you can actually see the effect on real device before back to the previous activity) before closing. How can I fix this annoying issue?

Update with more info
This annoying behaviour only happened If the previous activity is in portrait mode, if the previous one is landscape, it is just fine. To me it looks like something to do with Android framework when fade in/out activities with different screenOrientation settings.

Update with the cause
After some deep reading through Google’s API, I think I found the reason that cause this annoying behaviour, check out here:

Unless you specify otherwise, a configuration change (such as a change in screen orientation, language, input devices, etc) will cause your current activity to be destroyed, going through the normal activity lifecycle process of onPause(), onStop(), and onDestroy() as appropriate. If the activity had been in the foreground or visible to the user, once onDestroy() is called in that instance then a new instance of the activity will be created, with whatever savedInstanceState the previous instance had generated from onSaveInstanceState(Bundle).

So what happened behind the scenes when back button is clicked: currnet VideoView Activity (landscape) is destroyed, a new VideoView Activity (portrait) is created due screenOrientation configuration has been changed, and destoryed immidiately (where you can see the effects on screen), last activity in stack is shown. this also explain why this annoying behaviour disappered if last activity has the same screenOrientation settngs.

I am still trying to figure out how to bypass this activity recreation due to configuration change. As it stated in API, overriding
onConfigurationChanged(Configuration), however, since I explicitly define screenOrientation in xml, onConfigurationChanged() is not called, lots of similiar SO has been discussed before, like this one.

Please provide answer on the right direction.

Thanks,
Y

  • 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-05-26T13:46:33+00:00Added an answer on May 26, 2026 at 1:46 pm

    Try adding calls to VideoView’s suspend(), resume() and stopPlayback() in your activity’s onPause(), onResume() and onDestroy() methods:

    @Override
    protected void onResume() {
        mVideoView.resume();
        super.onResume();
    }
    
    @Override
    protected void onPause() {
        mVideoView.suspend();
        super.onPause();
    }
    
    @Override
    protected void onDestroy() {
        mVideoView.stopPlayback();
        super.onDestroy();
    }
    

    The VideoView class implementation varies from one device to another (and the class itself is very sparsely documented), but the Gallery3D code from AOSP does call the above methods in its MovieView activity lifecycle methods, so hopefully most devices should at least make itself looks good in that scenario.

    If it still looks bad, you might want to override onBackPressed() in your activity to maybe hide the VideoView or some similar hacks to conceal the annoying behavior 🙂

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

Sidebar

Related Questions

I have application A defined as below: <application android:icon=@drawable/icon android:label=@string/app_name> <activity android:name=com.example.MyExampleActivity android:label=@string/app_name> <intent-filter>
In my Android Application I have a Google MapView Activity and I am facing
I'm writing my first Android application and I have one activity that I'd like
In my Android application, I have an activity with three layouts: A left layout,
In my Android application i have a tracker activity in which i retrieve the
I try to play with Service in Android, my application contain an Activity with
I have activity in my application and i have set android:configChanges=orientation in my menifest
I have an application that records activity in a table (Oracle 10g). The logging
I have an single Activity application that starts a Service and binds to it.
I have an application that reuses an Activity an unknown number of times. It

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.