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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:09:10+00:00 2026-06-18T11:09:10+00:00

I have an app that is starting up from boot. But it’s crashing. When

  • 0

I have an app that is starting up from boot. But it’s crashing. When I start it up from a button the service just work. I have all the permissons..

My manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.my.app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="16" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.VIBRATE"/>

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.my.app.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:enabled="true" android:name=".StartUpService" />
        <receiver
            android:name="com.my.app.StartUpReceiver"
            android:enabled="true"
            android:exported="false" >
        </receiver>
        <receiver android:name="com.my.app.BootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

BootReceiver:

package com.my.app;

import java.util.Calendar;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
        Calendar cal = Calendar.getInstance();
        Intent i = new Intent(context, StartUpReceiver.class);
        PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
        am.cancel(pi);
        am.setInexactRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 5*60*1000, pi);
    }
}

StartUpReceiver:

package com.my.app;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class StartUpReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Intent service = new Intent(context, StartUpService.class);
        context.startService(service);
    }
} 

StartUpService:

package com.my.app;

import java.io.ByteArrayOutputStream;
import java.net.URLEncoder;

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.IBinder;
import android.os.Vibrator;
import android.util.Log;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.widget.Toast;

public class StartUpService extends Service {   
    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        return;
    }

    @Override
    public void onDestroy() {
        return;
    }

    @Override
    public void onStart(Intent intent, int startid) { 

        String preferences = "SERVICE";

        SharedPreferences settings = getSharedPreferences(preferences, 0);

        SharedPreferences.Editor editor = settings.edit();
        editor.putBoolean("firstrun", false);
        editor.commit();

        CookieSyncManager.getInstance().sync();
        CookieManager cookie_manager = CookieManager.getInstance();

        String cookies = cookie_manager.getCookie("myurl");
        if(cookies != null) {
            int index = cookies.indexOf("sessiecode");
            if(index != -1) {
                String[] cookie = cookies.split("sessiecode=");
                String c = cookie[cookie.length - 1]; 
                new GetInteger().execute("myurl");
            }
        }


    }

    class GetInteger extends AsyncTask<String, String, String>{
        @Override
        protected String doInBackground(String... uri) {

            try {
                HttpClient httpclient = new DefaultHttpClient();
                HttpResponse response;  

                HttpGet post = new HttpGet(uri[0]);

                response = httpclient.execute(post);
                StatusLine statusLine = response.getStatusLine();

                if(statusLine.getStatusCode() == HttpStatus.SC_OK){                 
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    response.getEntity().writeTo(out);
                    out.close();
                    String responseString = out.toString();
                    return responseString;
                } else { 
                    response.getEntity().getContent().close();
                    Log.e("com.my.app", "HTTPRequest error");
                }

            } catch (Exception e) {
                Log.e("com.my.app", "Error: " + e.getMessage());
                e.printStackTrace();
            }
            */
            return "5"; 
        }

        @Override
        protected void onPostExecute(String result) {
            super.onPostExecute(result);

            int responseInt = Integer.parseInt(result);
            int NOTIF_ID = 1234;  
            NotificationManager notifManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
            notifManager.cancel(NOTIF_ID);
            if(responseInt > 0) {

                Notification note = new Notification(R.drawable.ic_note, "Nieuw privébericht", System.currentTimeMillis());  
                PendingIntent pintent = PendingIntent.getActivity(One2xsService.this, 0, new Intent(StartUpService.this, MainActivity.class), 0); 

                String noteString;
                if(responseInt > 1) {
                    noteString = "Je hebt " + responseInt + " ongelezen berichten";
                } else {
                    noteString = "Je hebt 1 ongelezen bericht";                     
                }

                note.setLatestEventInfo(One2xsService.this, "Nieuw privébericht", noteString, pintent);  
                note.flags = Notification.FLAG_AUTO_CANCEL;
                notifManager.notify(NOTIF_ID, note); 

                Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
                v.vibrate(200);
            }

        }

    }

}

I hope anyone can help!

Edit, Log:

02-02 19:00:27.100: E/AndroidRuntime(261): FATAL EXCEPTION: main
02-02 19:00:27.100: E/AndroidRuntime(261): java.lang.RuntimeException: Unable to start service com.my.app.StartUpService@40518b30 with Intent { cmp=com.my.app/.StartUpService }: java.lang.IllegalStateException: CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2052)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.app.ActivityThread.access$2800(ActivityThread.java:117)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:994)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.os.Handler.dispatchMessage(Handler.java:99)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.os.Looper.loop(Looper.java:123)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.app.ActivityThread.main(ActivityThread.java:3683)
02-02 19:00:27.100: E/AndroidRuntime(261):  at java.lang.reflect.Method.invokeNative(Native Method)
02-02 19:00:27.100: E/AndroidRuntime(261):  at java.lang.reflect.Method.invoke(Method.java:507)
02-02 19:00:27.100: E/AndroidRuntime(261):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-02 19:00:27.100: E/AndroidRuntime(261):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-02 19:00:27.100: E/AndroidRuntime(261):  at dalvik.system.NativeStart.main(Native Method)
02-02 19:00:27.100: E/AndroidRuntime(261): Caused by: java.lang.IllegalStateException: CookieSyncManager::createInstance() needs to be called before CookieSyncManager::getInstance()
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.webkit.CookieSyncManager.getInstance(CookieSyncManager.java:81)
02-02 19:00:27.100: E/AndroidRuntime(261):  at com.blay.one2xs.One2xsService.onStart(One2xsService.java:56)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.app.Service.onStartCommand(Service.java:428)
02-02 19:00:27.100: E/AndroidRuntime(261):  at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2039)
02-02 19:00:27.100: E/AndroidRuntime(261):  ... 10 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-18T11:09:11+00:00Added an answer on June 18, 2026 at 11:09 am

    as in log :

    CookieSyncManager::createInstance() needs to be called before
    CookieSyncManager::getInstance()

    you will need to call createInstance() before calling getInstance() method as :

    CookieSyncManager.createInstance(getApplicationContext); 
    CookieSyncManager.getInstance().sync();
    CookieManager cookie_manager = CookieManager.getInstance();
    
    • 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 that works for all versions starting from Android-8. Now,
I'm just starting out learning OBJ-C but I do have an end-goal app that
Starting from the assumption that I have deleted all unnecessary files, i have my
I have an app that is built starting from a tab bar controller. It's
I have an app that handles streaming video. Starting with a .m3u8 playlist, it
have an app that finds your GPS location successfully, but I need to be
I have an App that downloads and displays images from URL's. This works fine
I have an app that received JSON data from the server. Currently when I
We have an app that allows users to send e-mails from our system. It
I have a WPF app that from time to time needs to perform a

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.