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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:09:19+00:00 2026-06-17T07:09:19+00:00

I want a simple service without Binder. Just start the service at boot time

  • 0

I want a simple service without Binder. Just start the service at boot time and no destroy of the service.
I have build a Service with a location manager. But the service does not start. What ist wrong?

public class WayService extends Service implements LocationListener {

blabla
...

    public WayService(Context context) {
        this.mContext = context;
        getLocation();
    }

    public Location getLocation() {
        try {
            locationManager = (LocationManager) mContext
                    .getSystemService(LOCATION_SERVICE);

            // getting GPS status
            isGPSEnabled = locationManager
                    .isProviderEnabled(LocationManager.GPS_PROVIDER);

            // getting network status
            isNetworkEnabled = locationManager
                    .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

            if (!isGPSEnabled && !isNetworkEnabled) {
                // no network provider is enabled
            } else {
                this.canGetLocation = true;
                // First get location from Network Provider
                if (isNetworkEnabled) { //! hinzugefuegt
                    locationManager.requestLocationUpdates(
                            LocationManager.NETWORK_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("Network", "Network");
                    if (locationManager != null) {
                        location = locationManager
                                .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();
                        }
                    }
                }
                // if GPS Enabled get lat/long using GPS Services
                if (isGPSEnabled) {
                    if (location == null) {
                        locationManager.requestLocationUpdates(
                                LocationManager.GPS_PROVIDER,
                                MIN_TIME_BW_UPDATES,
                                MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                        Log.d("GPS Enabled", "GPS Enabled");
                        if (locationManager != null) {
                            location = locationManager
                                    .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                            if (location != null) {
                                latitude = location.getLatitude();
                                longitude = location.getLongitude();
                                time = location.getTime();
                                speed = location.getSpeed();
                            }
                        }
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        return location;
    }

blabla
...

@Override
    public void onLocationChanged(Location location) {
        double latitude = getLatitude();
        double longitude = getLongitude();
        String mlat = String.valueOf(latitude);
        String mlon = String.valueOf(longitude);
        new PostData().execute(mlat, mlon, mtime);
    }

The Manifest looks like this:

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service
            android:name=".WayService"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name" >
        </service>


        <receiver android:name="WayStartServiceReceiver" >
        </receiver>

    </application>

And:

public class WayStartServiceReceiver extends BroadcastReceiver {

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

here is my logfile:

01-09 13:35:29.317: D/dalvikvm(452): newInstance failed: no <init>()
01-09 13:35:29.337: D/AndroidRuntime(452): Shutting down VM
01-09 13:35:29.337: W/dalvikvm(452): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-09 13:35:29.367: E/AndroidRuntime(452): FATAL EXCEPTION: main
01-09 13:35:29.367: E/AndroidRuntime(452): java.lang.RuntimeException: Unable to instantiate service de.app.trackmyway.WayService: java.lang.InstantiationException: de.app.trackmyway.WayService
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:1929)
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.app.ActivityThread.access$2500(ActivityThread.java:117)
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:985)
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.os.Looper.loop(Looper.java:123)
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.app.ActivityThread.main(ActivityThread.java:3683)
01-09 13:35:29.367: E/AndroidRuntime(452):  at java.lang.reflect.Method.invokeNative(Native Method)
01-09 13:35:29.367: E/AndroidRuntime(452):  at java.lang.reflect.Method.invoke(Method.java:507)
01-09 13:35:29.367: E/AndroidRuntime(452):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-09 13:35:29.367: E/AndroidRuntime(452):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-09 13:35:29.367: E/AndroidRuntime(452):  at dalvik.system.NativeStart.main(Native Method)
01-09 13:35:29.367: E/AndroidRuntime(452): Caused by: java.lang.InstantiationException: de.app.trackmyway.WayService
01-09 13:35:29.367: E/AndroidRuntime(452):  at java.lang.Class.newInstanceImpl(Native Method)
01-09 13:35:29.367: E/AndroidRuntime(452):  at java.lang.Class.newInstance(Class.java:1409)
01-09 13:35:29.367: E/AndroidRuntime(452):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:1926)
01-09 13:35:29.367: E/AndroidRuntime(452):  ... 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-17T07:09:20+00:00Added an answer on June 17, 2026 at 7:09 am

    i hope We cannot create the constructor in Android service. Like we cannot create the constructor in our Activity. we will be having our default override method as follow.

    @Override
        public IBinder onBind(Intent intent) {
            return null;
        }
    

    else try to use oncreate in Service class. in the on-create call the method getLocation(); If you will try with the oncreate means surely it will work. you wont get any issue.

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

Sidebar

Related Questions

I have created a simple web-service using Java. i want to load jars related
I have a simple WCF Data Services service and I want to expose a
I have written a very simple accessibility service, the code works fine without an
I have a very simple web service using Rack, without Rails that I will
I have a simple web service and I want to make a method which
I am creating a very simple web service and I don't want to bother
I have a huge table and I want simple sorting. It could be so
I want launch simple php daemon on Ubuntu without fork. source f.php: #!/usr/bin/php <?php
For a new project, we want to build a web service in Java using
I want to use to implement only REST service - a very simple one

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.