On Fri, Jul 2, 2010 at 1:02 PM, Bret Foreman <bret.fore...@gmail.com> wrote:
> Intent.setClass needs a Context for the first argument. Replacing
> cb.getContext with "this" causes a compiler error. Do you mean I
> should call getApplicationContext?

No, I mean you should use the proper value of "this".

Your code is:

try {
                                                       Intent myIntent
= new Intent();

myIntent.setClass(cb.getContext(), SensorService.class);
                                                       startService( myIntent );
                                               } catch( Exception e ){

android.util.Log.e( getString(R.string.app_name) , "Unable to
start sensor service" , e );
                                               }

Do you see your call to startService()? That is a method on Context.
Whatever object you are in, it is a Context. If "this" gives you a
compiler error, yet startService() does not, that means this code
snippet comes from an inner class, and so you need to scope your
"this" to the proper outer class (e.g., MyActivity.this).

> Here's the full trace:

Perhaps Eclipse considers that to be a trace. It is useless to me and,
presumably, to you.

If you continue execution past this point, your exception, with a full
exception message and two-tier stack trace, will be written to logcat.
This will be accessible from Eclipse via the DDMS perspective, in the
LogCat tab, in red.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
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