Android : Java Null Pointer Exception in Android while Instantiating an IntentService from an Activity

on Wednesday, August 6, 2014


I am creating an application which has an activity and an intent service which will be called from this activity. The purpose of the Intent service is to send a file from the android device to a remote server. The file is created by the application.


The problem is : I am getting a Null pointer exception when I try to instantiate the intent service from a method(which i created) in the activity.


This is the error Eclipse is showing :


This is the error Eclipse is showing


The Console Output from the Eclipse is :



[2014-08-07 10:40:02 - ddms] null
java.nio.BufferOverflowException
at java.nio.HeapByteBuffer.put(HeapByteBuffer.java:200)
at com.android.ddmlib.JdwpPacket.movePacket(JdwpPacket.java:235)
at com.android.ddmlib.Debugger.sendAndConsume(Debugger.java:347)
at com.android.ddmlib.Client.forwardPacketToDebugger(Client.java:665)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:344)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)


And the Code that calls starts the intent service is :



Intent iservice = new Intent(Viewer1.this, DataUploader.class);
startService(iservice);


Viewer1 is the Activity from which I want to call the service. DataUploader is the Intent service I am trying to start.


Can anyone help me in debugging the error. I am sure that there is no error in any other part of the activity.


Note : I am calling the startService() method from a method which I created.


0 comments:

Post a Comment