| Author |
Message |
stilwalli Developer

Joined: 21 Jul 2008 Posts: 35
|
Posted: Tue Jul 29, 2008 10:38 am Post subject: |
|
|
| It worked. These were warn message. But not sure why this was getting printed as I had already given the permission. |
|
| Back to top |
|
 |
|
|
 |
bbevol Once Poster

Joined: 08 Oct 2008 Posts: 1
|
Posted: Wed Oct 08, 2008 7:21 pm Post subject: |
|
|
I believe this is out of date now. Here is a modified version for Android 1.0
| Java: |
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class MyStartupIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
/* Create intent which will finally start the Main-Activity. */
Intent myStarterIntent = new Intent(context, MyStarterIntent .class);
/* Set the Launch-Flag to the Intent. */
myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
/* Send the Intent to the OS. */
context.startActivity(myStarterIntent);
}
}
|
in the Manifest file
| XML: | <receiver android:name="MyStartupIntentReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.HOME" />
</intent-filter> |
|
|
| Back to top |
|
 |
ninor Moderator


Joined: 14 Aug 2008 Posts: 180 Location: Barcelona, Spain
|
Posted: Thu Oct 09, 2008 7:52 am Post subject: |
|
|
Thanks bbevol!
I formatted your code to look nicer! _________________
AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit |
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Thu Oct 09, 2008 10:20 am Post subject: |
|
|
| Is it possible to make BOOT_COMPLETED automatically start a service? According the manifest docs you can specify an intent-filter for <service> but I can't get it to work. |
|
| Back to top |
|
 |
Azalar Junior Developer

Joined: 13 Jan 2009 Posts: 24
|
Posted: Tue Feb 24, 2009 1:59 pm Post subject: |
|
|
Did anyone get this to work in the end?
I am also wanting to start a service up when the device has started up |
|
| Back to top |
|
 |
MrSnowflake Moderator


Joined: 16 Feb 2008 Posts: 1437 Location: Flanders, Belgium
|
Posted: Tue Feb 24, 2009 4:28 pm Post subject: |
|
|
| bbevol's code works for Services too. |
|
| Back to top |
|
 |
|
|
 |
sushil kathade Junior Developer

Joined: 19 Feb 2009 Posts: 12
|
Posted: Wed Mar 25, 2009 2:55 pm Post subject: |
|
|
| puyopuy wrote: | Thanks for your detailed explanation, I will test it again this week.  |
hi
can any one send me same example by using broadcast receiver
and some tutorial on how to use broadcast receiver to start a service when booting is completed?
I am using SDK 1.1
thanks |
|
| Back to top |
|
 |
kabhijit Once Poster

Joined: 06 Jan 2010 Posts: 1
|
Posted: Thu Jan 07, 2010 2:03 pm Post subject: Getting error on android 1.5 |
|
|
Hi,
Basically i am very new to Android development. I tried your code but got error. I am using android 1.5 and the line throwing error is
| Java: | myStarterIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH); |
in this line "NEW_TASK_LAUNCH" is giving error.
Also i removed this line and ran the project. It succeeded. but when i started the emulator from command line i got following error
| Quote: | | The application Services Demo(process com.example) has stopped unexpectedly please try again |
Can you please help me?
Thanks in advance |
|
| Back to top |
|
 |
Profete162 Developer

Joined: 27 Nov 2009 Posts: 44
|
Posted: Wed Feb 03, 2010 9:46 pm Post subject: |
|
|
yeah! that's a really nice tutorial.
Just a question: when I launch the intent, my app is showing and is launched. That's of course a normal behavior.
But i would like this app to come in background instead. I just want my app to be in background.
Any idea/proposition? |
|
| Back to top |
|
 |
|