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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:43:34+00:00 2026-06-17T14:43:34+00:00

Here is the following code: public class NotificationsReceiver extends BroadcastReceiver { public static final

  • 0

Here is the following code:

public class NotificationsReceiver extends BroadcastReceiver {
    public static final String INTENT_EXTRA_NOTIFICATION_INFO="intent_extra_notification_info";

    @Override
    public void onReceive(Context context, Intent intent) {
        NotificationInfo info=(NotificationInfo)intent.getSerializableExtra(INTENT_EXTRA_NOTIFICATION_INFO);
        NotificationTextInfo fields=DataSourceWrapper.getInstance().getNotificationTextInfo(info);
        NotificationManager manager=(NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification=new Notification(android.R.drawable.alert_dark_frame, "1", info.getId());
        notification.when=new Date().getTime();
        notification.setLatestEventInfo(context, fields.getTitle(), fields.getDescription(), null);
        manager.notify((int)info.getId(), notification);
    }
}

BroadcastReceiver exists for AlarmManager.
When it works for the first time all is good, but when it executes for the second time it shows a NullPointerException in a row when I get some info from Intent, therefor Intent will be clear after the first executing.

Now my question is: How can I copy data from Intent into a new one in order to fix NullPointerException?

Logcat:

01-23 17:00:00.578: E/receiver(8442): receive
01-23 17:00:00.608: E/AndroidRuntime(8442): FATAL EXCEPTION: main
01-23 17:00:00.608: E/AndroidRuntime(8442): java.lang.RuntimeException: Unable to start receiver com.ulnda.mypsych.receivers.NotificationsReceiver: java.lang.NullPointerException
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2408)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.app.ActivityThread.access$1500(ActivityThread.java:139)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.os.Looper.loop(Looper.java:154)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.app.ActivityThread.main(ActivityThread.java:4945)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at java.lang.reflect.Method.invokeNative(Native Method)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at java.lang.reflect.Method.invoke(Method.java:511)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at dalvik.system.NativeStart.main(Native Method)
01-23 17:00:00.608: E/AndroidRuntime(8442): Caused by: java.lang.NullPointerException
01-23 17:00:00.608: E/AndroidRuntime(8442):     at com.ulnda.mypsych.db.DataSourceWrapper.getNotificationTextInfo(DataSourceWrapper.java:68)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at com.ulnda.mypsych.receivers.NotificationsReceiver.onReceive(NotificationsReceiver.java:27)
01-23 17:00:00.608: E/AndroidRuntime(8442):     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2397)
01-23 17:00:00.608: E/AndroidRuntime(8442):     ... 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-17T14:43:36+00:00Added an answer on June 17, 2026 at 2:43 pm

    It seems that DataSourceWrapper.getInstance() returns null so you need to check if the return value is not null before executing the other code:

    <ReturnClassName> instance = DataSourceWrapper.getInstance();
    if(instance != null) {
        NotificationTextInfo fields = instance.getNotificationTextInfo(info);
        // ...
    

    Please note that you need to exchange <ReturnClassName> with your real class name I don’t know that DataSourceWrapper class.

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

Sidebar

Related Questions

I have the following code: public class Tests { public static void main(String[] args)
I came across the following code: public class LinePrinter { public static void main(String
Consider the following code :- public class UsingWait1{ public static void main(String... aaa){ CalculateSeries
In the following code: public class A { public A():this(null){} public A(string b){/*code here*/}
I have following code: public static void ProcessStep(Action action) { //do something here if
Let us have the following code: public class TestGenerics { static <T> void mix(ArrayList<T>
I have the following code: public class DeserializeAndCompare { public static List<string> IntoXML() {
Given the following Java code: public class Test { static private class MyThread extends
I have the following code: public abstract class A<T extends B<? extends A<T>>>{ @Override
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called

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.