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

The Archive Base Latest Questions

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

I am trying to create a VideoViewer fragment. Below are the 2 cases I

  • 0

I am trying to create a VideoViewer fragment. Below are the 2 cases I have tried and the observations. For both the cases the fragment’s view is inflated from the following layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" 
android:layout_height="match_parent"
android:gravity="center">

<VideoView android:id="@+id/fragment_video_viewer_video"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center" />
</RelativeLayout>

Case 1: VideoView without media controller – works fine. Below is the code for the onActivityCreated method

/* Initialize the variables here, retrieve views and  */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Assignment for the local variables
    mVideoView = (VideoView) getView().findViewById(R.id.fragment_video_viewer_video);
    mVideoView.setVideoPath("/sdcard/family_guy_test.3gp");//(videoUri);
    mVideoView.requestFocus();
    mVideoView.start();
}

Case 2: VideoView with media controller – App Crashes when I touch on the VideoView. Below is the code for the onActivityCreated method

/* Initialize the variables here, retrieve views and  */
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    // Assignment for the local variables
    mVideoView = (VideoView) getView().findViewById(R.id.fragment_video_viewer_video);
    mVideoView.setVideoPath("/sdcard/family_guy_test.3gp");//(videoUri);
    MediaController mediaController = new MediaController(getActivity().getApplicationContext());
    mediaController.setAnchorView(mVideoView);
    mVideoView.setMediaController(mediaController);
    mVideoView.requestFocus();
}

The logcat output is given below :

WARN/WindowManager(124): Failed looking up window
WARN/WindowManager(124): java.lang.IllegalArgumentException: Requested window null does not exist
WARN/WindowManager(124):     at com.android.server.WindowManagerService.windowForClientLocked(WindowManagerService.java:9398)
WARN/WindowManager(124):     at com.android.server.WindowManagerService.addWindow(WindowManagerService.java:1906)
WARN/WindowManager(124):     at com.android.server.WindowManagerService$Session.add(WindowManagerService.java:6876)
WARN/WindowManager(124):     at android.view.IWindowSession$Stub.onTransact(IWindowSession.java:66)
WARN/WindowManager(124):     at com.android.server.WindowManagerService$Session.onTransact(WindowManagerService.java:6848)
WARN/WindowManager(124):     at android.os.Binder.execTransact(Binder.java:288)
WARN/WindowManager(124):     at dalvik.system.NativeStart.run(Native Method)
WARN/WindowManager(124): Attempted to add window with token that is not a window: null.  Aborting.
WARN/dalvikvm(8144): threadid=1: thread exiting with uncaught exception (group=0x400287f0)
ERROR/AndroidRuntime(8144): FATAL EXCEPTION: main
ERROR/AndroidRuntime(8144): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
ERROR/AndroidRuntime(8144):     at android.view.ViewRoot.setView(ViewRoot.java:505)
ERROR/AndroidRuntime(8144):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
ERROR/AndroidRuntime(8144):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
ERROR/AndroidRuntime(8144):     at android.widget.MediaController.show(MediaController.java:304)
ERROR/AndroidRuntime(8144):     at android.widget.MediaController.show(MediaController.java:249)
ERROR/AndroidRuntime(8144):     at android.widget.VideoView.toggleMediaControlsVisiblity(VideoView.java:567)
ERROR/AndroidRuntime(8144):     at android.widget.VideoView.onTouchEvent(VideoView.java:518)
ERROR/AndroidRuntime(8144):     at android.view.View.dispatchTouchEvent(View.java:3766)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
ERROR/AndroidRuntime(8144):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
ERROR/AndroidRuntime(8144):     at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
ERROR/AndroidRuntime(8144):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:863)
ERROR/AndroidRuntime(8144):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
ERROR/AndroidRuntime(8144):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
ERROR/AndroidRuntime(8144):     at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
ERROR/AndroidRuntime(8144):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
ERROR/AndroidRuntime(8144):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
ERROR/AndroidRuntime(8144):     at android.os.Handler.dispatchMessage(Handler.java:99)
ERROR/AndroidRuntime(8144):     at android.os.Looper.loop(Looper.java:123)
ERROR/AndroidRuntime(8144):     at android.app.ActivityThread.main(ActivityThread.java:4627)
ERROR/AndroidRuntime(8144):     at java.lang.reflect.Method.invokeNative(Native Method)
ERROR/AndroidRuntime(8144):     at java.lang.reflect.Method.invoke(Method.java:521)
ERROR/AndroidRuntime(8144):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
ERROR/AndroidRuntime(8144):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
ERROR/AndroidRuntime(8144):     at dalvik.system.NativeStart.main(Native Method)
WARN/ActivityManager(124):   Force finishing activity com.comp.ias/.MainActivity
WARN/ActivityManager(124): Activity pause timeout for HistoryRecord{43f755b0 com.comp.ias/.MainActivity}
WARN/WindowManager(124): No window to dispatch pointer action 1
  • 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-26T02:53:47+00:00Added an answer on May 26, 2026 at 2:53 am

    I figured out that the problem was actually in the context I was using. I had to use, Activity context instead of the application context. More specifically, I had to do :

    MediaController mediaController = new MediaController(getActivity());
    

    The documentation on when to use which context is very sparse. Sometimes, any of the context can be used. Sometimes, we need to use a specific context. I think the intuition behind usage of context is that, “if an instance of a class is binded to an activity, use activity context, else use application context”.

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

Sidebar

Related Questions

I'm trying create new object from a module class in VBA, and I have
I am trying create a data.frame from which to create a graph. I have
Trying to create a black line in my view to separate text blocks but
Trying to create Database as follows: USE Master GO IF NOT EXISTS(SELECT [Name] FROM
I am trying to programatically create an image from the current frame of a
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I'm trying create an immutable object and initialise it from xml config file in
I trying create a class derivated from System.Web.UI.Page and in override Render i set
I am trying create a 'live' view where our clients can edit the colors
Trying to create the following routine in MySQL Workbench yields a This object's DDL

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.