Android:
public class LocationService extends Service {
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startI
Alternately,
You can use your own Application class and call from wherever you needs (especially non-activities).
public class App extends Application {
protected static Context context = null;
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
}
public static Context getContext() {
return context;
}
}
And register your Application class :
Then call :
App.getContext();