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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:42:45+00:00 2026-06-02T13:42:45+00:00

I am developing Galaxy Tab 10.1 app by using honeycomb 3.1 and i have

  • 0

I am developing Galaxy Tab 10.1 app by using honeycomb 3.1 and i have a videoview and mediacontroller in fragment on the right side. I defined VideoView and MediaController in Layout xml file and instantiate and manipulate them in the related java file.

As you guys konw, in the java file, i set VideoView’s controller to MediaController and set MediaController’s media player to VideoView, i defined.

Below is fragment layout xml file

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <VideoView
        android:id="@+id/video"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <MediaController
        android:id="@+id/controller"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal" />
</LinearLayout>

and java code file is below

public class ContentFragment extends Fragment {
    private VideoView mVideo;
    private MediaController mController;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.content, null);
        mVideo = (VideoView)view.findViewById(R.id.video);
        mController = (MediaController)view.findViewById(R.id.controller);
        mVideo.setMediaController(mController);
        mController.setMediaPlayer(mVideo);

        return view;
    }

    public void playVideo(String path) {
        mVideo.setVideoPath(path);
        mVideo.requestFocus();
    }
}

But while running this app, there occurs

NullPointerException with
android.widget.MediaController.show(MediaController.java:305)

I tried to solve this error a whole day but i can’t get the reason why. actullay there isn’t enought information for this.
Dose any body know what i did wrong? or have solutions?
Please let me know.

Thanks.

  • 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-02T13:42:47+00:00Added an answer on June 2, 2026 at 1:42 pm

    Sorry, but instead of defining the MediaController in XML, you should instantiate it programatically (see the docs):

    mController = new MediaController(getActivity());
    

    And then attach it to the VideoView:

    mVideo.setMediaController(mController);
    

    Also, as far as I can tell, adding mController.setMediaPlayer(mVideo); is pointless since the call to setMediaController seems to take care of that as well.

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

Sidebar

Related Questions

I'm developing a tablet app on a Samsung Galaxy Tab 10.1 (Android 3.2). The
Presently I am developing Android application for Samsung galaxy tab. I am using default
I have a Samsung Galaxy Tab (Android 2.2 Froyo, etc) that I am developing
I have samsung i5503 galaxy. I got a problem in developing app. First I
Im developing an App which is going to be used on Samsung Galaxy SII
developing iphone app, I have used a UIImageview and i have set an image
Developing iphone application using makkit framework. I have got the map view integrated in
I am developing an app for samsung galaxy S2, version 2.3.3. I want to
I am developing an app for tablets like samsung galaxy, moto xoom and kindle
I'm developing a physics game using AndEngine with box2d physics engine. I have a

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.