andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

Launch Activity on System/Emulator Startup

Goto page Previous  1, 2, 3
 
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials
Author Message
stilwalli
Developer
Developer


Joined: 21 Jul 2008
Posts: 35

PostPosted: Tue Jul 29, 2008 10:38 am    Post subject: Reply with quote

It worked. These were warn message. But not sure why this was getting printed as I had already given the permission.
Back to top
View user's profile Send private message
bbevol
Once Poster
Once Poster


Joined: 08 Oct 2008
Posts: 1

PostPosted: Wed Oct 08, 2008 7:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
ninor
Moderator
Moderator


Joined: 14 Aug 2008
Posts: 180
Location: Barcelona, Spain

PostPosted: Thu Oct 09, 2008 7:52 am    Post subject: Reply with quote

Thanks bbevol!
I formatted your code to look nicer!

_________________
AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
Back to top
View user's profile Send private message
MrSnowflake
Moderator
Moderator


Joined: 16 Feb 2008
Posts: 1437
Location: Flanders, Belgium

PostPosted: Thu Oct 09, 2008 10:20 am    Post subject: Reply with quote

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
View user's profile Send private message
Azalar
Junior Developer
Junior Developer


Joined: 13 Jan 2009
Posts: 24

PostPosted: Tue Feb 24, 2009 1:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
MrSnowflake
Moderator
Moderator


Joined: 16 Feb 2008
Posts: 1437
Location: Flanders, Belgium

PostPosted: Tue Feb 24, 2009 4:28 pm    Post subject: Reply with quote

bbevol's code works for Services too.
Back to top
View user's profile Send private message
sushil kathade
Junior Developer
Junior Developer


Joined: 19 Feb 2009
Posts: 12

PostPosted: Wed Mar 25, 2009 2:55 pm    Post subject: Reply with quote

puyopuy wrote:
Thanks for your detailed explanation, I will test it again this week. Laughing



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
View user's profile Send private message
kabhijit
Once Poster
Once Poster


Joined: 06 Jan 2010
Posts: 1

PostPosted: Thu Jan 07, 2010 2:03 pm    Post subject: Getting error on android 1.5 Reply with quote

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
View user's profile Send private message
Profete162
Developer
Developer


Joined: 27 Nov 2009
Posts: 44

PostPosted: Wed Feb 03, 2010 9:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Novice Tutorials All times are GMT + 1 Hour
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.