Launch Activity on System/Emulator Startup

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

Postby stilwalli » Tue Jul 29, 2008 10:38 am

It worked. These were warn message. But not sure why this was getting printed as I had already given the permission.
stilwalli
Developer
Developer
 
Posts: 35
Joined: Mon Jul 21, 2008 8:13 am

Top

Postby bbevol » Wed Oct 08, 2008 7:21 pm

I believe this is out of date now. Here is a modified version for Android 1.0

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.content.BroadcastReceiver;
  3.  
  4. import android.content.Context;
  5.  
  6. import android.content.Intent;
  7.  
  8.  
  9.  
  10.  
  11.  
  12. public class MyStartupIntentReceiver extends BroadcastReceiver {
  13.  
  14.  
  15.  
  16.      @Override
  17.  
  18.      public void onReceive(Context context, Intent intent) {
  19.  
  20.           /* Create intent which will finally start the Main-Activity. */
  21.  
  22.           Intent myStarterIntent = new Intent(context, MyStarterIntent .class);
  23.  
  24.           /* Set the Launch-Flag to the Intent. */
  25.  
  26.           myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  27.  
  28.           /* Send the Intent to the OS. */
  29.  
  30.           context.startActivity(myStarterIntent);
  31.  
  32.      }
  33.  
  34. }
  35.  
  36.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


in the Manifest file

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <receiver android:name="MyStartupIntentReceiver" >
  2.  
  3.             <intent-filter>
  4.  
  5.                  <action android:name="android.intent.action.BOOT_COMPLETED" />
  6.  
  7.                  <category android:name="android.intent.category.HOME" />
  8.  
  9.             </intent-filter>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4
bbevol
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Oct 08, 2008 7:16 pm

Postby ninor » Thu Oct 09, 2008 7:52 am

Thanks bbevol!
I formatted your code to look nicer!
Image AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Postby MrSnowflake » Thu Oct 09, 2008 10:20 am

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.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby Azalar » Tue Feb 24, 2009 1:59 pm

Did anyone get this to work in the end?
I am also wanting to start a service up when the device has started up
Azalar
Junior Developer
Junior Developer
 
Posts: 24
Joined: Tue Jan 13, 2009 6:09 pm

Postby MrSnowflake » Tue Feb 24, 2009 4:28 pm

bbevol's code works for Services too.
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Top

Postby sushil kathade » Wed Mar 25, 2009 2:55 pm

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



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
sushil kathade
Junior Developer
Junior Developer
 
Posts: 12
Joined: Thu Feb 19, 2009 1:01 pm

Getting error on android 1.5

Postby kabhijit » Thu Jan 07, 2010 2:03 pm

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
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. myStarterIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

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
The application Services Demo(process com.example) has stopped unexpectedly please try again


Can you please help me?

Thanks in advance
kabhijit
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Jan 06, 2010 10:21 am

Postby Profete162 » Wed Feb 03, 2010 9:46 pm

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?
Profete162
Experienced Developer
Experienced Developer
 
Posts: 67
Joined: Fri Nov 27, 2009 6:07 pm

Top
Previous

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 8 guests