Error While calling service from activity
<p>below is the code I use to call a service from my activity.
I want to call the service when the progress bar reaches its max value. what would be the right way to do it? as my progress bar reached to max then i got error....</p>

<pre><code>    Handler progressHandler = new Handler()
    {
        public void handleMessage(Message msg) 
        {
            if (dialog.getProgress() == dialog.getMax())
            {

                //Log.d(TAG, "onClick: stopping srvice");

                // stopService(new Intent(oddg.this, MyService.class));

                Log.d(TAG, "onClick: starting service");
                startService(new Intent(oddg.this, MyService.class)); 
            }

            dialog.incrementProgressBy(increment);
        }
    };
</code></pre>

<p>Logs: </p>

<pre><code>ERROR/AndroidRuntime(725): java.lang.RuntimeException: Unable to create service org.androidpeople.dialog.MyService: android.util.AndroidRuntimeException: 
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. 
</code></pre>
