Extending abstract class in Android: A LocationProvider

This is probably a simple/dumb problem. I can't find any documentation on it. I want to create my own LocationProvider in Android. LocationProvider is an abstract class, with no constructor.

import android.location.LocationProvider;

public class provider extends LocationProvider {
    public provider() {

    public int getAccuracy() {
        // TODO Auto-generated method stub
        return 0;


    public boolean supportsSpeed() {
        // TODO Auto-generated method stub
        return false;

Eclipse gives me the error here: "Implicit super constructor LocationProvider() is not visible. Must explicitly invoke another constructor"

But of course the empty super constructor is not visible - there are no constructors for LocationProvider. How am I supposed to create a subclass of an abstract class with no constructor?

For example, this throws the same error:

public abstract class topabstractclass {
    private topabstractclass() {

class mysubclass extends topabstractclass{
    mysubclass() {      

I cannot modify Android's LocationProvider, so I can't create a constructor that's public. Is this just an intrinsically non-subclassible class? Does android just not expect us to ever create LocationProviders? How are other LocationProviders done? Can anyone provide an example?


You are correct in your assumption. It is impossible to extend an abstract class in which all constructors are private. This means, correctly, that Google does NOT want you extending LocationProvider.

First, note that other projects may clone LocationProvider. They then create their subclasses of it, and can use them as they see fit.

Now, I would guess you want to know why LocationProvider is restricted in such a manner. That is explained by the documentation:

Each provider has a set of criteria under which it may be used; for example, some providers require GPS hardware and visibility to a number of satellites; others require the use of the cellular radio, or access to a specific carrier's network, or to the internet. They may also have different battery consumption characteristics or monetary costs to the user. The Criteria class allows providers to be selected based on user-specified criteria.

Here we have to read between the lines a bit. Consider how much of that information comes directly from the carriers and is phone-specific. This means that tampering with it in your app may stop a device from functioning, since its provider is no longer following its esoteric rules. This is why Android sets up all the providers for us. (This link is really handy to keep around. It will show you how to access that location info without your own provider.)

So, no, you cannot implictly* extend LocationProvider. You must use one that already exists, because they are specially designed to work between the carrier, the hardware, and the software.

*As shown in @Funtik's answer, you can extend LocationProvider using a String, ILocationManager signature. However, it's undocumented, marked with {@hide}, and unsupported in previous versions, so you may have to do some dancing around to get the correct construction method.

Need Your Help

parsing xml via simplexml

php xml simplexml

I try to figure out, how to extract an dropdownlist of the following xml data via simplexml.

Upload Data from Local System Ms Access to Web Sql Server?

sql sql-server vb.net winforms

I have a windows forms application which maintains the billing details of a company's employees. The application stores and manipulates data in an MS Access database.