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

  • Home
  • SEARCH
  • 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 9191983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:49:07+00:00 2026-06-17T20:49:07+00:00

I am having hard time running webview using my application as it crashes the

  • 0

I am having hard time running webview using my application as it crashes the app right way.

Java

package com.unext.unextlibrary;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;


  @SuppressLint("SetJavaScriptEnabled")
   public class InitializeVideo extends Activity {

WebView mWebview;

@Override
@JavascriptInterface
public void onCreate(Bundle icicle) {
    setContentView(R.layout.activity_video_play);

    getWindow().requestFeature(Window.FEATURE_PROGRESS);
    mWebview  = new WebView(this);

    mWebview.getSettings().setJavaScriptEnabled(true); // enable javascript

    final Activity activity = this;

    mWebview.setWebViewClient(new WebViewClient() {
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            Toast.makeText(activity, description, Toast.LENGTH_SHORT).show();
        }
    });

    mWebview .loadUrl("http://www.google.com");
    setContentView(mWebview );
}
}

XML CODE

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

 <android.webkit.WebView android:id="@+id/WebView"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
</android.webkit.WebView>

</LinearLayout>

Inside my manifest i am targeting sdk version as 17

Manifest goes here

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />

  <uses-permission android:name="android.permission.INTERNET"/>

 <activity
        android:theme="@style/Theme.Video"
        android:configChanges="orientation|screenSize"
        android:name="com.unext.unextlibrary.InitializeVideo"
        android:label="@string/app_name" >
     </activity> 

Also my logcat output shows as follow

01-24 07:11:09.091: E/AndroidRuntime(2457): FATAL EXCEPTION: main
    01-24 07:11:09.091: E/AndroidRuntime(2457): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.unext.unextlibrary/com.unext.unextlibrary.InitializeVideo}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.os.Handler.dispatchMessage(Handler.java:99)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.os.Looper.loop(Looper.java:137)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.ActivityThread.main(ActivityThread.java:5039)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at java.lang.reflect.Method.invokeNative(Native Method)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at java.lang.reflect.Method.invoke(Method.java:511)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at dalvik.system.NativeStart.main(Native Method)
    01-24 07:11:09.091: E/AndroidRuntime(2457): Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:229)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at com.unext.unextlibrary.InitializeVideo.onCreate(InitializeVideo.java:24)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.Activity.performCreate(Activity.java:5104)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    01-24 07:11:09.091: E/AndroidRuntime(2457):     ... 11 more
  • 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-17T20:49:09+00:00Added an answer on June 17, 2026 at 8:49 pm

    Try this way,

    public void onCreate(Bundle icicle) {
    getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.activity_video_play);
    

    its because, requestFeature() must be called before calling setContentView();

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

Sidebar

Related Questions

I am having a hard time understanding: http://www.syterra.com/Fit/AppConfigFiles.html If my application and fixtures are
I'm having some hard time running my app on Heroku - The app runs
I am having a hard time running a M2Crypto SSLServer with EXPORT grade ciphers.
I am having hard time finding a way to display a loading image in
I'm having a hard time getting Sinatra running on my local setup, Ubuntu Karmic
I'm running Kohana 3, and having a hard time understanding the Auth module, or
I'm looking hard at WF 4.0 right now, but I'm having a hard time
I'm having a hard time running Enunciate on my project. The project is a
I'm having a hard-time debugging a local variable. I'm running gcc 4.2 , XCode
Im having a hard time converting cdr files to jpgs for previews using c#.net.

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.