I found my "errors" or mistakes.  So I found out that I was setting
the constructor incorrectly which as DanH stated is why the
InstantiationException is thrown. I had:

public _Constructor(String name)
{
    super(name);
}

WHICH IS INCORRECT.

The proper way is to not include a String name argument, such as:

public _Constructor()
{
    super(name);
}

While we are on the subject of IntentServices, a few things that threw
me off were the following:

I implemented the onCreate() and onStartCommand(...) methods and it
was entering those with no problem but for some reason it wasn't
entering the onHandleIntent(Intent intent) method at all.
I found out that it was because you had to call super.onCreate() and
super.onStartCommand().

By the way all these tips were on other threads but I failed to
connect the solutions to the problem but now they are all in one
thread.

Thanks.



On Jul 29, 12:47 pm, DanH <danhi...@ieee.org> wrote:
> InstantiationException occurs when an exception is thrown out of a
> constructor.  Generally there should be another exception reported as
> causing the InstantiationException, and the stack trace should point
> to the specific lines that are in error.  Stack trace is your friend,
> and you should be grateful -- their are poor children programming on
> Symbian devices who have no stack trace.
>
> On Jul 29, 11:24 am, Wall-E <bashee...@gmail.com> wrote:
>
>
>
> > I am trying to start an IntentService inside my Broadcast Receiver
> > ( so inside of onReceive() ):
>
> >     public class SmsMessageReceiver extends BroadcastReceiver
> >     {
> >         .
> >         .
> >         .
> >         public void onReceive(.....)
> >         {
> >              .
> >              .
> >              .
> >              Intent mServiceIntent = new Intent(context,
> > SmsParserService.class );
> >              mServiceIntent.putExtra("phoneNumber", fromAddress);
> >              mServiceIntent.putExtra("smsMessage",
> > message.getMessageBody());
> >                context.startService(mServiceIntent);
> >         }
>
> >     }
>
> >     So if I change the IntentService class to a regular Service class,
> > although it has funny behavior, it still goes into the
> > onStartCommand(...) and onCreate() methods, but for the IntentService,
> > before going into any of those methods it throws an
> > InstantiationException and in the detailMessage it just says
> > "com.tvismobile.SmsParserService" which is what my Service is labeled
> > as in the Manifest file.
>
> > Is there something special you have to do to get IntentService
> > started?
>
> > Any help is appreciated.

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to