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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:59:16+00:00 2026-05-27T03:59:16+00:00

Android app gives me an error now: package com.martijngijselaar.rooster; import android.os.Bundle; import android.view.MotionEvent; import

  • 0

Android app gives me an error now:

package com.martijngijselaar.rooster;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebviewActivity extends MainActivity {

    private WebView myWebView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

        WebView myWebView = (WebView)findViewById(R.id.webview);

        WebSettings webSettings = myWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        myWebView.setWebViewClient(new WebViewClient());

        myWebView.requestFocus(View.FOCUS_DOWN);
        myWebView.setOnTouchListener(new View.OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                    case MotionEvent.ACTION_UP:
                        if (!v.hasFocus()) {
                            v.requestFocus();
                        }
                        break;
                }
                return false;
            }
        });
    }   

    public void onResume() {
        super.onResume();
        if ( isOnline() == true )
            myWebView.loadUrl(webLink);
        else if ( isOnline() == false )
            showNoConnectionDialog();
    }
}

And this is the logcat:

11-25 12:33:34.697: E/AndroidRuntime(494): FATAL EXCEPTION: main 11-25
12:33:34.697: E/AndroidRuntime(494): java.lang.RuntimeException:
Unable to resume activity
{com.martijngijselaar.rooster/com.martijngijselaar.rooster.WebviewActivity}:
java.lang.NullPointerException 11-25 12:33:34.697:
E/AndroidRuntime(494): at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
11-25 12:33:34.697: E/AndroidRuntime(494): at
android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
11-25 12:33:34.697: E/AndroidRuntime(494): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
11-25 12:33:34.697: E/AndroidRuntime(494): at
android.app.ActivityThread.access$2300(ActivityThread.java:125) 11-25
12:33:34.697: E/AndroidRuntime(494): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-25 12:33:34.697: E/AndroidRuntime(494): at
android.os.Handler.dispatchMessage(Handler.java:99) 11-25
12:33:34.697: E/AndroidRuntime(494): at
android.os.Looper.loop(Looper.java:123) 11-25 12:33:34.697:
E/AndroidRuntime(494): at
android.app.ActivityThread.main(ActivityThread.java:4627) 11-25
12:33:34.697: E/AndroidRuntime(494): at
java.lang.reflect.Method.invokeNative(Native Method) 11-25
12:33:34.697: E/AndroidRuntime(494): at
java.lang.reflect.Method.invoke(Method.java:521) 11-25 12:33:34.697:
E/AndroidRuntime(494): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-25 12:33:34.697: E/AndroidRuntime(494): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 11-25
12:33:34.697: E/AndroidRuntime(494): at
dalvik.system.NativeStart.main(Native Method) 11-25 12:33:34.697:
E/AndroidRuntime(494): Caused by: java.lang.NullPointerException 11-25
12:33:34.697: E/AndroidRuntime(494): at
com.martijngijselaar.rooster.WebviewActivity.onResume(WebviewActivity.java:46)
11-25 12:33:34.697: E/AndroidRuntime(494): at
android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
11-25 12:33:34.697: E/AndroidRuntime(494): at
android.app.Activity.performResume(Activity.java:3823) 11-25
12:33:34.697: E/AndroidRuntime(494): at
android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
11-25 12:33:34.697: E/AndroidRuntime(494): … 12 more

Blockquote

  • 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-27T03:59:17+00:00Added an answer on May 27, 2026 at 3:59 am

    You are really close. You just need to move the code that loads the url into onResume:

    public void onResume(){
    super.onResume();
     if ( isOnline() == true )
                myWebView.loadUrl(webLink);
    }
    

    onResume is called right after onCreate so it will be called in both the case where it’s the first load and when coming back from the pause.

    Update based on discussion in the comments:
    To move the web view to an instance variable:

    public class WebviewActivity extends MainActivity {
    
      private WebView myWebView;
    
      public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);
    
        myWebView = (WebView)findViewById(R.id.webview);
         //the rest of your onCreate method here)
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Android app with a ListActivity in the main view. The list
My android app gives the following when I try to run it.... The application
I'm trying to create layout inflater, but app crashes and gives NullException error in
My android app has a two word app name, and the 2nd word doesn't
I'm building an Android app and I want to copy the text value of
We have an Android app and a Web Service. We want to download part
I've got an Android app which has a periodic background Service. I want this
I'm writing an Android app where users can upload video to Youtube. I'd like
I want my Android app to take a picture, as part of something larger
I created a native Android app that basically hosts a webView control. That webView

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.