[android-developers] Re: Intent variable required for onStart function
Er... the onStart() method takes Intent as a parameter, so that is what your onStart() method should be taking. This code looks like it was from a pre-1.0 version of the platform (and whoever wrote it didn't use @Override, naughty naughty!). On Tue, Nov 25, 2008 at 3:09 PM, steve_macleod [EMAIL PROTECTED]wrote: Hi, Quick question, I am running a service (code below). I have a problem with the super.onStart(intent, startId) line. The onStart call expects and Intent as paremeter. How can I get this from the context below? Thanks package com.stevemacleod.prankapp; import java.io.IOException; import android.app.Service; import android.content.Context; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.os.IBinder; public class PrankService extends Service { MediaPlayer player = null; String str; public IBinder onBind(Intent intent) { return null; } public void onStart(int startId, Bundle arguments) { super.onStart(intent, startId); player = MediaPlayer.create((Context)this, R.raw.groove_arm); player.start(); } public void onDestroy() { super.onDestroy(); player.stop(); } } -- Dianne Hackborn Android framework engineer [EMAIL PROTECTED] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Intent variable required for onStart function
Hi Dianne, OK Im new with this, but how do I get the initiating Intent object from the onStart function? thanks, On Nov 25, 11:43 pm, Dianne Hackborn [EMAIL PROTECTED] wrote: Er... the onStart() method takes Intent as a parameter, so that is what your onStart() method should be taking. This code looks like it was from a pre-1.0 version of the platform (and whoever wrote it didn't use @Override, naughty naughty!). On Tue, Nov 25, 2008 at 3:09 PM, steve_macleod [EMAIL PROTECTED]wrote: Hi, Quick question, I am running a service (code below). I have a problem with the super.onStart(intent, startId) line. The onStart call expects and Intent as paremeter. How can I get this from the context below? Thanks package com.stevemacleod.prankapp; import java.io.IOException; import android.app.Service; import android.content.Context; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.os.IBinder; public class PrankService extends Service { MediaPlayer player = null; String str; public IBinder onBind(Intent intent) { return null; } public void onStart(int startId, Bundle arguments) { super.onStart(intent, startId); player = MediaPlayer.create((Context)this, R.raw.groove_arm); player.start(); } public void onDestroy() { super.onDestroy(); player.stop(); } } -- Dianne Hackborn Android framework engineer [EMAIL PROTECTED] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Intent variable required for onStart function
Oh yeah should also say the example code im working from is in the Android Essentials book, and its quite outdated now... On Nov 25, 11:43 pm, Dianne Hackborn [EMAIL PROTECTED] wrote: Er... the onStart() method takes Intent as a parameter, so that is what your onStart() method should be taking. This code looks like it was from a pre-1.0 version of the platform (and whoever wrote it didn't use @Override, naughty naughty!). On Tue, Nov 25, 2008 at 3:09 PM, steve_macleod [EMAIL PROTECTED]wrote: Hi, Quick question, I am running a service (code below). I have a problem with the super.onStart(intent, startId) line. The onStart call expects and Intent as paremeter. How can I get this from the context below? Thanks package com.stevemacleod.prankapp; import java.io.IOException; import android.app.Service; import android.content.Context; import android.content.Intent; import android.media.MediaPlayer; import android.os.Bundle; import android.os.IBinder; public class PrankService extends Service { MediaPlayer player = null; String str; public IBinder onBind(Intent intent) { return null; } public void onStart(int startId, Bundle arguments) { super.onStart(intent, startId); player = MediaPlayer.create((Context)this, R.raw.groove_arm); player.start(); } public void onDestroy() { super.onDestroy(); player.stop(); } } -- Dianne Hackborn Android framework engineer [EMAIL PROTECTED] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them.- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Intent variable required for onStart function
steve_macleod wrote: Hi Dianne, OK Im new with this, but how do I get the initiating Intent object from the onStart function? She's saying your onStart() callback should look like this: @Override public void onStart(Intent intent, int startId) { super.onStart(intent, startId); player = MediaPlayer.create((Context)this, R.raw.groove_arm); player.start(); } -- Mark Murphy (a Commons Guy) http://commonsware.com Android Training on the Ranch! -- Mar 16-20, 2009 http://www.bignerdranch.com/schedule.shtml --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Intent variable required for onStart function
On Tue, Nov 25, 2008 at 3:51 PM, steve_macleod [EMAIL PROTECTED] wrote: Oh yeah should also say the example code im working from is in the Android Essentials book, and its quite outdated now... Maybe you should use that book for a monitor stand instead of letting it give you bad advice. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---