RxJava default error handler - java

Sorry, is there a possibility to set default error handler in RxJava?
For instance, I some code in Utils.kt file:
fun BaseFragment.callGallery(view: View){
view.clicks().bindToLifecycle(this).subscribe {
RxPaparazzo.takeImage(this)
.usingGallery()
.subscribe { response ->
throw RuntimeException("Where is this exception from?")
}
}
}
But in stacktrace there's no any hint about Utils.kt or about any of my file.
I understand that I can set onError in every subscriber. with code like:
.subscribe ({ response ->
....
}, { it.printStackTrace() })
But I'd prefer to set one default onError for all subscribers. How can I do it?
Stacktrace:
05-07 12:11:48.246 10966-10966/ru.egslava.rxfluxtest E/AndroidRuntime: FATAL EXCEPTION: main
Process: ru.egslava.rxfluxtest, PID: 10966
java.lang.RuntimeException: Unable to destroy activity {ru.egslava.rxfluxtest/rx_activity_result.HolderActivity}: rx.exceptions.OnErrorNotImplementedException: Where is this exception from?
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3831)
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3849)
at android.app.ActivityThread.-wrap5(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1398)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: rx.exceptions.OnErrorNotImplementedException: Where is this exception from?
at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:374)
at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:371)
at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44)
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:157)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:120)
at rx.exceptions.Exceptions.throwOrReport(Exceptions.java:204)
at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:144)
at rx.internal.operators.OperatorOnErrorResumeNextViaFunction$4.onNext(OperatorOnErrorResumeNextViaFunction.java:153)
at rx.internal.operators.OperatorMap$MapSubscriber.onNext(OperatorMap.java:74)
at rx.internal.operators.OperatorMerge$MergeSubscriber.emitScalar(OperatorMerge.java:391)
at rx.internal.operators.OperatorMerge$MergeSubscriber.tryEmit(OperatorMerge.java:353)
at rx.internal.operators.OperatorMerge$InnerSubscriber.onNext(OperatorMerge.java:838)
at rx.observers.Subscribers$5.onNext(Subscribers.java:229)
at rx.internal.operators.OperatorZip$Zip.tick(OperatorZip.java:264)
at rx.internal.operators.OperatorZip$Zip$InnerSubscriber.onNext(OperatorZip.java:335)
at rx.internal.operators.OperatorMap$MapSubscriber.onNext(OperatorMap.java:74)
at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:268)
at rx.Subscriber.setProducer(Subscriber.java:211)
at rx.internal.operators.OperatorMap$MapSubscriber.setProducer(OperatorMap.java:99)
at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:79)
at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:75)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:8452)
at rx.internal.operators.OperatorZip$Zip.start(OperatorZip.java:214)
at rx.internal.operators.OperatorZip$ZipSubscriber.onNext(OperatorZip.java:156)
at rx.internal.operators.OperatorZip$ZipSubscriber.onNext(OperatorZip.java:122)
at rx.internal.util.ScalarSynchronousObservable$WeakSingleProducer.request(ScalarSynchronousObservable.java:268)
at rx.Subscriber.setProducer(Subscriber.java:209)
at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:79)
at rx.internal.util.ScalarSynchronousObservable$1.call(ScalarSynchronousObservable.java:75)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:50)
at rx.internal.operators.OnSubscribeLift.call(OnSubscribeLift.java:30)
at rx.Observable.unsafeSubscribe(Observable.java:8452)
at rx.internal.util.ScalarSynchronousObservable$4.call(ScalarSynchronousObservable.java:227)
at rx.internal.util.ScalarSynchronousObservable$4.call(ScalarSynchronousObservable.java:220)
at rx.Observable.unsafeSubscribe(Observable.java:8452)
at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:248)

RxJava has Plugins to support cross cutting concerns nicely. In particular RxJavaErrorHandler is desiged to attached global error handling behavior like so:
RxJavaPlugins.getInstance().registerErrorHandler(object : RxJavaErrorHandler() {
override fun handleError(e: Throwable?) {
println("Global error handler: $e")
}
})
Observable.just(1).concatMap({ Observable.error<Int>(Exception("Just throwing $it")) })
.subscribe({
println("I'll not be called")
}, {
println("Specific error handler: $it")
})
The above code would print:
Error occurred java.lang.Exception: Just throwing 1
A default error handler: java.lang.Exception: Just throwing 1
I suspect that you'd also be interested in improving diagnostic information available in stacktraces when you do have an unhandled error. For that there's a RxJavaStackTracer that when used RxJavaPlugins.getInstance().registerObservableExecutionHook(RxJavaStackTracer()) enhaces stack trace information. The Stacktraces and subscribeOn/observeOn issue on github is a good read on the topic.

You can use the onErrorResumeNext operator. Example usage:
fun BaseFragment.callGallery(view: View){
view
.clicks()
.bindToLifecycle(this)
.onErrorResumeNext { err -> log(err); Observable.empty() }
.subscribe {
// do stuff
}
}

Related

FATAL EXCEPTION: CameraX-audio encoding thread

I am recording videos using the camera X library. When i take video for 5 seconds before that (i,e)two seconds if i close the video its crashing with above error.How to handle this run time exception in android cameraX library
E/AndroidRuntime: FATAL EXCEPTION: CameraX-audio encoding thread
Process: .debug, PID: 4625
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2698)
at androidx.camera.core.VideoCapture.audioEncode(VideoCapture.java:705)
at androidx.camera.core.VideoCapture$1.run(VideoCapture.java:340)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.os.HandlerThread.run(HandlerThread.java:65)
sometimes the below issue
FATAL EXCEPTION: CameraX-video encoding thread
Process: <packagename>, PID: 10794
java.lang.NullPointerException: Attempt to invoke virtual method 'int android.media.MediaCodec.dequeueOutputBuffer(android.media.MediaCodec$BufferInfo, long)' on a null object reference
at androidx.camera.core.VideoCapture.videoEncode(VideoCapture.java:604)
at androidx.camera.core.VideoCapture$2.run(VideoCapture.java:348)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.os.HandlerThread.run(HandlerThread.java:65)
in this samples also not fixed yet
https://github.com/android/camera-samples/issues/2#issuecomment-546812852
By adding a callback to videoCapture.startRecording(videoFile, executor, onVideoSavedCallback); you should be able to handle the exeption in the onError method.
/**
* Define callback that will be triggered after a video has been taken and saved to disk
*/
private VideoCapture.OnVideoSavedCallback onVideoSavedCallback= new VideoCapture.OnVideoSavedCallback() {
#SuppressLint("RestrictedApi")
#Override
public void onVideoSaved(#NonNull File file) {
Log.d("VIDEO_CAPTURE", "Video capture succeeded");
}
#Override
public void onError(int videoCaptureError, #NonNull String message, #Nullable Throwable cause) {
Log.e("VIDEO_CAPTURE", "Video capture failed");
if (cause != null) {
cause.printStackTrace();
Toast.makeText(context,"Video capture failed",Toast.LENGTH_LONG).show();
}
}
};

java.lang.IllegalStateException: Expected to be called on the main thread but was RxCachedThreadScheduler-1

I'm new here. I'm trying to use RxJava library for Android but getting error. The logic is to handle click events on button, then map it to get value from EditText, and then flatmap it to Single<String> which resolves value via network. I'm trying to run flatmap on IO thread using Schedulers.io(), but getting error:
E/MainActivity: Login error
java.lang.IllegalStateException: Expected to be called on the main thread but was RxCachedThreadScheduler-1
at com.jakewharton.rxbinding3.internal.Preconditions.checkMainThread(mainThread.kt:28)
at com.jakewharton.rxbinding3.view.ViewClickObservable.subscribeActual(ViewClickObservable.kt:35)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableFilter.subscribeActual(ObservableFilter.java:30)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableDoOnEach.subscribeActual(ObservableDoOnEach.java:42)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableFlatMapSingle.subscribeActual(ObservableFlatMapSingle.java:48)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableObserveOn.subscribeActual(ObservableObserveOn.java:45)
at io.reactivex.Observable.subscribe(Observable.java:12267)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
The code:
RxView.clicks(this.btnNext)
.map(none -> this.editTextKey.getText().toString())
.filter(x -> !x.isEmpty())
.flatMapSingle(key -> new Api(key).id())
.observeOn(AndroidSchedulers.mainThread())
.subscribeOn(Schedulers.io())
.subscribe(this::showId, err -> {
Log.e(this.getClass().getSimpleName(), "Login error", err);
})
Api class has this method:
class Api {
private final String apiKey;
public Api(final String apiKey) {
this.apiKey = apiKey;
}
Single<String> id() {
// some code to fetch user id by key from remote server
}
}
Can someone help me to solve this issue? I need to run network calls on background thread, but receive the result on main thread.
You're using .subscribeOn(Schedulers.io()) for RxView.clicks(this.btnNext) event source. It means that RxView will subscribe on IO thread but it's not allowed. You should configure scheduler for your Single<String> source by flatMapSingle(key -> new Api(key).id().subscribeOn(Schedulers.io())). So the full code should be:
RxView.clicks(this.btnNext)
.map(none -> this.editTextKey.getText().toString())
.filter(x -> !x.isEmpty())
.flatMapSingle(key -> new Api(key).id().subscribeOn(Schedulers.io()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::showId, err -> {
Log.e(this.getClass().getSimpleName(), "Login error", err);
})
Now network operation will be performed on IO thread, view subscription on main thread.

DBFlow SQLite.delete() throwing java.lang.IllegalArgumentException: Please use query()

I one of the from projects I have DBFlow library for SQLite.
The problem occurs when I'm trying to remove some data from Table.
override fun removeOldEventPlanners(): Single<Boolean> {
LogMgr.v(TAG, "removeOldEventPlanners()")
return Single.create { emitter ->
RXSQLite.rx(SQLite.delete().from(EventPlanner::class.java)
.where(EventPlanner_Table.date_to.lessThan(Date(TimeUtil.getCurrentTime().time - CONST_30_DAYS_IN_MILLISECONDS)))
.or(EventPlanner_Table.deleted.`is`(1)))
.queryList()
.subscribe({ eventPlanners ->
LogMgr.d(TAG, "removeOldEventPlanners queryList() $eventPlanners")
emitter.onSuccess(true)
}, { throwable ->
LogMgr.e(TAG, "removeOldEventPlanners error", throwable)
emitter.onError(throwable)
})
}
}
This code throwing exception:
java.lang.IllegalArgumentException: Please use query(). The beginning is not a ISelect
at com.raizlabs.android.dbflow.sql.language.Where.checkSelect(Where.java:259)
at com.raizlabs.android.dbflow.sql.language.Where.queryList(Where.java:235)
at com.raizlabs.android.dbflow.rx2.language.RXModelQueriableImpl$2.call(RXModelQueriableImpl.java:61)
at com.raizlabs.android.dbflow.rx2.language.RXModelQueriableImpl$2.call(RXModelQueriableImpl.java:58)
at io.reactivex.internal.operators.single.SingleFromCallable.subscribeActual(SingleFromCallable.java:44)
at io.reactivex.Single.subscribe(Single.java:3575)
at io.reactivex.Single.subscribe(Single.java:3561)
at com.fs.wfm.storage.dbflow.DBFlowWfmStorageRepo$removeOldEventPlanners$1.subscribe(DBFlowWfmStorageRepo.kt:112)
at io.reactivex.internal.operators.single.SingleCreate.subscribeActual(SingleCreate.java:39)
at io.reactivex.Single.subscribe(Single.java:3575)
at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Anyone has an idea how to fix it?
delete does not return values, so using queryList() to return values as list is not correct and can be seen in the stacktrace.

Android rxJava Error handling with retrofit

I'm using the newer RX java where instead of
Observable.create(new Observable.OnSubscribeFunc<T>() {...});
this is used: (due to deprecation)
Observable.create(new Observable.OnSubscribe<T>() {...});
(This can be important as most example, tutorial, explonation uses the old one...)
Well, lets see my problem. I have a Java class, relevant parts from it:
private interface ApiManagerService {
#FormUrlEncoded
#POST("/login")
User getUser(#Field("username") String userName, #Field("password") String password);
}
private static RestAdapter restAdapter = new RestAdapter.Builder()
.setEndpoint(HOST)
.setLogLevel(RestAdapter.LogLevel.FULL)
.build();
private static ApiManagerService apiManager = restAdapter.create(ApiManagerService.class);
public static Subscription login(final String userName, final String password, Observer<User> observer) {
return Observable.create(new Observable.OnSubscribe<User>() {
#Override
public void call(Subscriber<? super User> subscriber) {
try {
User user = apiManager.getUser(userName, password);
subscriber.onNext(user);
subscriber.onCompleted();
} catch (RetrofitError e) {
subscriber.onError(e);
} catch (Throwable e) {
subscriber.onError(e);
}
}
}
).subscribeOn(Schedulers.io())
.retry(3)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(observer);
}
This code almost works perfectly, if everything is ok. But if I make an intentional error, like I turn off the WiFi.. than retrofit get the "UnKnownHostException"... as it should happen at the retrofit call (getUser) in the try catch block. But instead of handling the error to onError(Throwable t) --> where I could handle, it just crashes the app. So it is like if the error never gets to the catch block.
What is strange that HTTP errors (like 404, 401 etc.) is catched, got by onError(...) and everything is just fine.
Everything goes for 3 times before crash, as of .retry(3) but none gets into catch clause.
EDIT 1
LogCat Output:
01-08 16:19:31.576 15285-16162/asd.bdef.gh D/Retrofit﹕ ---- ERROR https://testapi.com/api/login
01-08 16:19:31.606 15285-16162/asd.bdef.gh D/Retrofit﹕ java.net.UnknownHostException: Unable to resolve host "testapi.com": No address associated with hostname
at java.net.InetAddress.lookupHostByName(InetAddress.java:394)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
at java.net.InetAddress.getAllByName(InetAddress.java:214)
at com.squareup.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:259)
at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:233)
at com.squareup.okhttp.internal.http.RouteSelector.nextUnconnected(RouteSelector.java:159)
at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:133)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:314)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:237)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:423)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:105)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:239)
at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25)
at retrofit.client.UrlConnectionClient.prepareRequest(UrlConnectionClient.java:68)
at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:37)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:841)
01-08 16:19:31.606 15285-16162/asd.bdef.gh D/Retrofit﹕ ---- END ERROR
01-08 16:19:31.977 15285-15285/asd.bdef.gh D/AndroidRuntime﹕ Shutting down VM
01-08 16:19:31.977 15285-15285/asd.bdef.gh W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41c9d8b0)
01-08 16:19:31.977 15285-15285/asd.bdef.gh E/AndroidRuntime﹕ FATAL EXCEPTION: main
the given api address is not the real one, but the real one is reachable. I just turned off the WiFi to test error handling.
And one more use-case: If I add to the observable .onExceptionResumeNext([2nd observable]) than it goes to the 2nd observable, and it not crashes. But this is not the solution of the problem.
EDIT 2
ApiManager.login(userName, pass, new Observer<User>() {
#Override
public void onCompleted() { }
#Override
public void onError(Throwable e) {
DialogManager.showBasicErrorDialog(getApplicationContext(), e.getLocalizedMessage());
logger.showLog("Login Not ok");
e.printStackTrace();
}
#Override
public void onNext(User user) {
logger.showLog("login ok, user: " + user.getName().toString());
{...}
}
});
EDIT 3
FATAL EXCEPTION: main
rx.exceptions.OnErrorFailedException: Error occurred when trying to propagate error to Observer.onError
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:175)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:97)
at rx.internal.operators.NotificationLite.accept(NotificationLite.java:144)
{...}
Caused by: java.lang.NullPointerException: Attempt to read from field 'rx.functions.Action0 rx.schedulers.TrampolineScheduler$TimedAction.action' on a null object reference
at rx.schedulers.TrampolineScheduler$InnerCurrentThreadScheduler.enqueue(TrampolineScheduler.java:85)
Thanks in advance for helping.
You don't have to build your own Observable with Retrofit, as Retrofit can directly return Observable:
http://square.github.io/retrofit/
Retrofit also integrates RxJava to support methods with a return type
of rx.Observable
#GET("/user/{id}/photo") Observable getUserPhoto(#Path("id")
int id);
(You won't have to handle errors by yourself)
Can you post the stacktrace of your crash ? As I think like you, that your application shouldn't crash.
It looks like you may be running into an issue has been fixed as of RxJava 1.0:
TrampolineScheduler NullPointerException

NullPointerException for method invocation on "this"

On my android project, I am getting an intermittent NullPointerException reported in both crashlytics and the play store for a null pointer exception when invoking one of my objects invokes a method on itself.
Here is the entirety of the method that has the NullPointerException:
#Override
public void notifyActivityStarted() {
startUpdatingLocation(); // <-- NullPointerException occurs here. This is line 83 of DefaultAndroidLocationProvider.java
}
private void startUpdatingLocation() {
final String bestProvider = getBestProviderName();
Log.d(LOGTAG, "Starting to update location for provider: " + bestProvider);
// If we don't have a location yet, then let's make sure we get one at
// least
// temporarily.
Location currentLoc = getLastLocationFromBestProvider();
if (currentLoc != null) {
Log.d(LOGTAG, "Hydrating with last location");
mLastLocation.hydrate(currentLoc);
}
mWorker = new WorkerThread("DefaultAndroidLocation");
// Get a location update every 10s from both network and GPS.
if (mManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
mManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
10000,
0,
DefaultAndroidLocationProvider.this,
mWorker.getLooper());
}
if (mManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
mManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
10000,
0,
DefaultAndroidLocationProvider.this,
mWorker.getLooper());
}
mIsUpdatingLocation = true;
shutdownInitiated = false;
}
Here is the stack trace:
java.lang.NullPointerException
at com.jingit.mobile.location.DefaultAndroidLocationProvider.notifyActivityStarted(DefaultAndroidLocationProvider.java:83)
at com.jingit.mobile.location.ActivityObserverSet.onStartObserved(ActivityObserverSet.java:48)
at com.jingit.mobile.location.LocationAwareFragment.onStart(LocationAwareFragment.java:41)
at android.support.v4.app.Fragment.performStart(Fragment.java:1484)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:941)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5633)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:896)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:712)
at dalvik.system.NativeStart.main(NativeStart.java)
I wasn't able to find anything to give me hints on the documentation for NullPointerException, and haven't been able to find any other helpful hints. Any thoughts or ideas would be greatly appreciated.

Categories