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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:56:10+00:00 2026-06-04T18:56:10+00:00

I’m fairly new to making Android application so I got a question. If I

  • 0

I’m fairly new to making Android application so I got a question.

If I got my application running and I wait for a few seconds my screen timeouts. The problem is that when I unlock my screen again my application is closed. I want the application to stay active when the screen times out, so that I don’t have to start the application all over again.

I don’t want the application to run in the background and also I do not want to disable the screen timeout. I just don’t want the application to close itself after the screen automatically times out.

Is there any chance of doing so?

_EDIT > Added some of my code.

 
Android Manifest

    <supports-screens
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:resizeable="true"
    android:anyDensity="true"
    />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    <uses-permission android:name="android.permission.RECORD_AUDIO" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />

    <uses-sdk android:minSdkVersion="10" />

    <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
            <activity
                    android:name=".SIOM_AndroidActivity"
                    android:label="@string/app_name"
                    android:screenOrientation="portrait"
                    android:configChanges="orientation|keyboardHidden" 
                    android:theme="@android:style/Theme.NoTitleBar" >
                    <intent-filter>
                            <action android:name="android.intent.action.MAIN" />
                            <category android:name="android.intent.category.LAUNCHER" />
                    </intent-filter>
            </activity>     
            <activity 
                    android:name="com.phonegap.DroidGap" 
                    android:label="@string/app_name" 
                    android:screenOrientation="portrait"
                    android:configChanges="orientation|keyboardHidden" > 
                    <intent-filter> 
                    </intent-filter> 
            </activity>
    </application>
</manifest>

 
Android Activity

package com.siom.android;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.phonegap.*;

public class SIOM_AndroidActivity extends DroidGap {
    /** Called when the activity is first created. */
    /** @Override */
    WebView mWebView;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
            super.init();
            super.clearCache();
            setContentView(R.layout.main);

            mWebView = (WebView) findViewById(R.id.webview);
            mWebView.getSettings().setJavaScriptEnabled(true);
            mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
            mWebView.setWebViewClient(new HelloWebViewClient());
            mWebView.setWebChromeClient(new MyWebChromeClient());

            mWebView.loadUrl("http://www.example.com/test.html");
    }

    // Maakt een WebChromeClient class aan
    final Context myApp = this;
    final class MyWebChromeClient extends WebChromeClient {

        // Zorgt er voor dat confirm werkt in WebView
        @Override
        public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(myApp)
            .setTitle("Title here")
            .setMessage(message)
            .setPositiveButton(android.R.string.ok,
                new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dialog, int which)
                    {
                        result.confirm();
                    }
                })
            .setNegativeButton(android.R.string.cancel,
                new DialogInterface.OnClickListener()
                {
                    public void onClick(DialogInterface dialog, int which)
                    {
                        result.cancel();
                    }
                })
            .create()
            .show();
                 return true;
        }

        // Zorgt er voor dat alert werkt in WebView
        @Override
        public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(myApp)
            .setTitle("Title here")
            .setMessage(message)
            .setPositiveButton(android.R.string.ok,
                new AlertDialog.OnClickListener()
                {
                    public void onClick(DialogInterface dialog, int which)
                    {
                        result.confirm();
                    }
                })
            .setCancelable(false)
            .create()
            .show();
                 return true;
        }
    }
    // Alle links worden in webview geladen
    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }

    // Geeft de back knop een goback actie
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) {
            mWebView.goBack();
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_MENU) {
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
  • 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-04T18:56:12+00:00Added an answer on June 4, 2026 at 6:56 pm

    After so many hours, days, weeks and even months trying to solve this problem I finally found it.

    If you look at the code I added in my first post you can see the follow two lines of code:

    super.init();
    super.clearCache();
    

    These two little guys crashed my application over and over and now after I look at it it’s no wonder they did. Added these because I was first working with PhoneGap and followed some tutorial somewhere that told me to add these lines. After removing these two lines again my application worked as usual again. Only removing one line didn’t work either.

    Sometimes programming can really be a hell.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm making a simple page using Google Maps API 3. My first. One marker

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.