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

The Archive Base Latest Questions

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

I have an application that fetches some text from a web page , and

  • 0

I have an application that fetches some text from a web page , and displays it on the screen. I would like to put after the text a video from the web . How could I do that ? If I do like the following code , the application crashes ( Null pointer exception) .

My code :

LinearLayout tt= (LinearLayout)findViewById(R.id.kiu);
WebView webview;
tt.addView(fin); // fin is the TextView


        webview.getSettings().setJavaScriptEnabled(true);
        webview.loadUrl("http://www.youtube.com/embed/j4Wmjl7jxQo");
        tt.addView(webview);

main.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    android:scrollbars="vertical"

    android:background="#FFFFFF"

    >
<LinearLayout
android:id="@+id/kiu"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="0dp">

  </LinearLayout>
</ScrollView>

I can’t figure out what should I do .. I would like my app to display this instead of this .

  • 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:36:15+00:00Added an answer on May 26, 2026 at 2:36 am

    You should post the stack trace from your exception. And highlight somehow which line it is pointing to. But off the top of my head here is what I notice:

        webview = (WebView) findViewById(R.id.webview);
        ...
        tt.addView(webview);
    

    findViewById(id) will return null unless the view is already on the screen. You don’t seem to have a WebView in your xml layout (which I assume is the one that is currently on the screen when this code is executing). Since you don’t have one in there findViewById will return null to you and on the next line when you try to use a method you’ll get a null pointer.

    You have a few options basically what it comes down to though is you won’t need both findViewById and .addView(), you’ll only need one or the other.

    You can either:

    replace webview = (WebView) findViewById(R.id.webview); with a WebView constroctor like so: webview = new WebView(this);

    Or

    you can add a WebView to your xml, leave findViewById how it is now but take out tt.addView(webview);

    Also be aware that since you’re displaying a youtube page in a webview the user is going to see the whole page, not just a full screen movie. And it is not going to start immediately, they will have to press the start button to get it going. If you are looking for something to just play the video automatically and not show anything else you’ll want a VideoView

    Here is a fairly straight forward example of VideoView in action You simply have to paste your url into the path variable. Although I am unsure if it knows how to decode a youtube url or not.

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

Sidebar

Related Questions

I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have developed an application that fetches the feed from a sever, displays the
I have a simple application that fetches some data from ONE table on db
I have an application that I would like to embed inside our companies CMS.
I have a web application that fetches a lot of content via ajax. For
I have a web application which fetches information from a web service. It works
I have this NodeJS app which fetches JSON-type response from a web application and
I have an ASP.NET page and some custom class that fetches a specified webpage
I have an application that sends messages to an external web service. I build
I have an application that displays an image inside of a Windows Forms PictureBox

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.