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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:29:23+00:00 2026-06-04T20:29:23+00:00

This is my Receiver.java import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.widget.Toast; public class

  • 0

This is my Receiver.java

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class Receiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        Toast.makeText(context, intent.getStringExtra("param"),Toast.LENGTH_SHORT).show();
    }

}

and this is my TaskActivity class..

    private void fillData() {

        // Fields from the database (projection)
        // Must include the _id column for the adapter to work
        String[] from = new String[] { TaskTable.COLUMN_SUMMARY };
        // Fields on the UI to which we map
        int[] to = new int[] { R.id.label };

        getLoaderManager().initLoader(0, null, this);

        adapter = new SimpleCursorAdapter(this, R.layout.task_row, null, from,to, 0);

        setListAdapter(adapter);
        //String[] from = new String[] { TaskTable.COLUMN_SUMMARY };
        String[] diffTime = new String[]{TaskTable.COLUMN_DIFFERENCE};
        if(diffTime.length!=0)
        {
            AlarmManager alarms = (AlarmManager)this.getSystemService(Context.ALARM_SERVICE);

            Receiver receiver = new Receiver();
            IntentFilter filter = new IntentFilter("ALARM_ACTION");
            registerReceiver(receiver, filter);

            Intent intent = new Intent("ALARM_ACTION");
            for(int i=0;i<diffTime.length;i++)
            {
                intent.putExtra("param", "WARNING!!! WARNING!!! Task is due now!");
                PendingIntent operation = PendingIntent.getBroadcast(this, 0, intent, 0);

                //alarms.set(AlarmManager.RTC_WAKEUP, d.getTime(), operation);
                alarms.set(AlarmManager.RTC_WAKEUP, d.getTime()+(Long.parseLong(diffTime[i])), operation);
                //System.out.println("YEAHHHHHH "+from[i]+" YOOOHOOOO "+(Long.parseLong(diffTime[i])));
            }
        }

    }

It returns error like this in the logcat

05-28 02:27:12.987: E/AndroidRuntime(525): FATAL EXCEPTION: main
05-28 02:27:12.987: E/AndroidRuntime(525): java.lang.RuntimeException: Unable to start activity ComponentInfo{mad.app/mad.app.TaskActivity}: java.lang.NumberFormatException: Invalid long: "difference"
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.os.Looper.loop(Looper.java:137)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.ActivityThread.main(ActivityThread.java:4424)
05-28 02:27:12.987: E/AndroidRuntime(525):  at java.lang.reflect.Method.invokeNative(Native Method)
05-28 02:27:12.987: E/AndroidRuntime(525):  at java.lang.reflect.Method.invoke(Method.java:511)
05-28 02:27:12.987: E/AndroidRuntime(525):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-28 02:27:12.987: E/AndroidRuntime(525):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-28 02:27:12.987: E/AndroidRuntime(525):  at dalvik.system.NativeStart.main(Native Method)
05-28 02:27:12.987: E/AndroidRuntime(525): Caused by: java.lang.NumberFormatException: Invalid long: "difference"
05-28 02:27:12.987: E/AndroidRuntime(525):  at java.lang.Long.invalidLong(Long.java:125)
05-28 02:27:12.987: E/AndroidRuntime(525):  at java.lang.Long.parse(Long.java:362)
05-28 02:27:12.987: E/AndroidRuntime(525):  at java.lang.Long.parseLong(Long.java:353)
05-28 02:27:12.987: E/AndroidRuntime(525):  at java.lang.Long.parseLong(Long.java:319)
05-28 02:27:12.987: E/AndroidRuntime(525):  at mad.app.TaskActivity.fillData(TaskActivity.java:141)
05-28 02:27:12.987: E/AndroidRuntime(525):  at mad.app.TaskActivity.onCreate(TaskActivity.java:48)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.Activity.performCreate(Activity.java:4465)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-28 02:27:12.987: E/AndroidRuntime(525):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-28 02:27:12.987: E/AndroidRuntime(525):  ... 11 more

If I’m not using “diffTime and for{}”, the application run smoothly by toasting the Warning message at the time the application starts… any ideas… thank you very much

  • 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-04T20:29:24+00:00Added an answer on June 4, 2026 at 8:29 pm

    Your error:

    String[] diffTime = new String[]{TaskTable.COLUMN_DIFFERENCE};
    

    TaskTable.COLUMN_DIFFERENCE sounds .. very much like a string, that could be named “difference”.

    Then you do this:

    Long.parseLong(diffTime[i])
    

    which causes your exception.

    Did you miss a step where you were supposed to load stuff from a database containing a “task table”?

    Edit:

    // Here you allocate "diffTime" to, what I must presume is the value "difference". 
        String[] diffTime = new String[]{TaskTable.COLUMN_DIFFERENCE};
        if(diffTime.length!=0)
        {
            ...
            ...
            for(int i=0;i<diffTime.length;i++)
            {
                ...
                ...
                alarms.set(AlarmManager.RTC_WAKEUP, d.getTime()+(Long.parseLong(diffTime[i])), operation);
            }
        }
    

    As you can see from your code, nowhere after the allocation of “diffTime” do you actually assign it a value other than TaskTable.COLUMN_DIFFERENCE – i.e. you are attempting to parse a String with the value “difference” – as shown by the cause of your stack trace:

    Caused by: java.lang.NumberFormatException: Invalid long: "difference"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi have one class like this import java.util.ArrayList; public class MobilePhone { private String
Imagine I have the following situation: Test1.java import java.lang.ref.WeakReference; public class Test1 { public
Running the following (example) code import java.io.*; public class test { public static void
Here is my code: import java.io.*; import java.util.*; import javax.comm.*; public class SMS {
I have a blank HelloWorld Application: package tutorials.TestReceivers; import android.app.Activity; import android.os.Bundle; public class
I receive a java.lang.NullPointerException when I click the button in this java application. import
I am trying to register a WebDeleting event receiver within SharePoint. This works fine
I want to raise an event from a .NET class, and receive this event
I have a Person Class and based on some help I received in this
I found a client/server code and I am getting this error: java.net.SocketException: Software caused

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.