I've tried to update my list after the SMS arrives. I get the receiver correctly, but when i try to send the receiver to my class I get the following error in the some phones.
05-20 09:50:57.749: E/AndroidRuntime(8873): java.lang.NullPointerException
05-20 09:50:57.749: E/AndroidRuntime(8873): at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
05-20 09:50:57.749: E/AndroidRuntime(8873): at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
05-20 09:50:57.749: E/AndroidRuntime(8873): at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
05-20 09:50:57.749: E/AndroidRuntime(8873): at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 09:50:57.749: E/AndroidRuntime(8873): at android.os.Looper.loop(Looper.java:153)
05-20 09:50:57.749: E/AndroidRuntime(8873): at android.app.ActivityThread.main(ActivityThread.java:5299)
05-20 09:50:57.749: E/AndroidRuntime(8873): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 09:50:57.749: E/AndroidRuntime(8873): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 09:50:57.749: E/AndroidRuntime(8873): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
05-20 09:50:57.749: E/AndroidRuntime(8873): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
05-20 09:50:57.749: E/AndroidRuntime(8873): at dalvik.system.NativeStart.main(Native Method)
my code works correctly in some phones.
I've send Broadcast with the following code:
Intent intent = new Intent(filtering);
intent.putExtra(RESULT, result);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
And I get receiver in the following code:
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
int resultCode = bundle
.getInt(NormalIncommingTextService.RESULT);
if (resultCode == Activity.RESULT_OK) {
RefreshList(getActivity());
}
}
}
};
I've registered and unregistered my receiver in onResume and onPause with this code:
LocalBroadcastManager.getInstance(this).registerReceiver(Home.receiver,
new IntentFilter(NormalIncommingTextService.NOTIFICATION));
// registerReceiver
LocalBroadcastManager.getInstance(this).unregisterReceiver(Home.receiver); // unregisterReceiver
I've search a lot in SO but couldn't find a working solution.
thanks in advance for your time
if you want to see any part of my code ask me.
NormalIncommingTextService.NOTIFICATION
is same with filtering
in my code.
// EDIT
this is line 297 @ LocalBroadcastManager
br.receivers.get(j).receiver.onReceive(mAppContext, br.intent);
more info on grepcode but i don't know what is the problem with that. this error happening on FragmentActivity
class while updating one Fragment data, i test it on Activity and worked fine
PS: in some phone I don't have any problem with updating data on FragmentActivity
//Answer
I've fix this problem, with using normal BroadCastReceiver
instead of LocalBroadcastManager