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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:56:36+00:00 2026-05-24T21:56:36+00:00

I have a service Activity and a thread in it. Problem is when phone

  • 0

I have a service Activity and a thread in it. Problem is when phone go to sleep mode, thread doesnt send http request And i check the network state if it is not connect i work to connect it but i get “Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS” error. But i already put the permission tag in AndroidManifest.xml. I also try this:

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK , "TAG");
wl.acquire();

But it is not solve my problem. phone Already go to sleep mode. Here is my checkNetwork code:

private boolean checkNetwork(){
    try{
        Context context = getApplicationContext();
        ConnectivityManager connectivity = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo info = connectivity.getActiveNetworkInfo();
        if(info == null){
            connectivity.setNetworkPreference(ConnectivityManager.TYPE_MOBILE);
            int status = connectivity.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, "cmwap");
            NetworkInfo info1 = connectivity.getActiveNetworkInfo();
            return false;
        }
        if (info.getState() == NetworkInfo.State.CONNECTED )
            return true;
        return false;

    }catch(Exception ex){
        return false;
    }
}

public class MainActivity extends Service {
…..

private Runnable httpThread = new Runnable() {

        public void run() {
//i send http request here
}
}

Please help..

  • 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-24T21:56:37+00:00Added an answer on May 24, 2026 at 9:56 pm

    Even though your application requested android.permission.WRITE_SECURE_SETTINGS in AndroidManifest.xml, it does not mean this permission will be granted to your application in runtime.

    In fact, for this particular permission (android.permission.WRITE_SECURE_SETTINGS) to be granted, your application must be signed with System certificate. And only vendor of the device can usually do that (for production devices).

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

Sidebar

Related Questions

I have an Activity communicating with and directly accessing a background Service's data members
I have an Android activity which in turn starts a thread. In the thread
I have an Activity calling a Service defined in IDownloaderService.aidl: public class Downloader extends
I have the following problem. My main activity consists of a ListView populated with
I have a Service which starts a thread during onCreate() . The thread is
I have question regarding the service and activity. I have one service which calls
I have a service bound to an activity. The service will access a JSON
I have an importer process which is running as a windows service (debug mode
I have a service which sends continously values to an activity through some custom
Here's scenario: I have 2 activities and one service First activity is a landing

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.