Launching application on Event?

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Launching application on Event?

Postby Androider » Thu Jan 24, 2008 7:53 am

Hi,
Can the application launched automatically when certian event occurs? Similar to Push Registry technology in J2ME.

Tnx.
Androider
Freshman
Freshman
 
Posts: 7
Joined: Thu Jan 17, 2008 8:03 am

Top

Postby plusminus » Thu Jan 24, 2008 11:01 am

Hello Androider,

please have a look at the :src: Launch Activity on System/Emulator Startup-Tutorial.

The process is pretty similar every time. You choose an Intent (or more), which are sent out by the AndroidOS, and:

a.) set up an IntentReceiver in your AndroidManifest.xml to make it start your Application. Examples: here or here
b.) directly start your application (Done here).

Hope I could help you :).

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby Androider » Thu Jan 24, 2008 1:41 pm

I tried both.. like DIAL and BOOT_COMPLETED, Working fine.

Let me be more specific. Suppose if i want to launch it when the Alaram rings?
Androider
Freshman
Freshman
 
Posts: 7
Joined: Thu Jan 17, 2008 8:03 am

Postby plusminus » Thu Jan 24, 2008 4:54 pm

Hello Androider,

Androider wrote:.. i want to launch it when the ALARM rings?

what do you mean with ALARM :?: :

You can setup an Alarm to be waked up like this, could be used for a wakeup-application ( click for more infos on Alarm-Manager ):

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                 try {
  2.  
  3.                         android.os.IServiceManager sm = android.os.ServiceManagerNative
  4.  
  5.                                         .getDefault();
  6.  
  7.                         android.app.IAlarmManager alarmService = android.app.IAlarmManager.Stub
  8.  
  9.                                         .asInterface(sm.getService("alarm"));
  10.  
  11.  
  12.  
  13.                         long timeToTrigger = System.currentTimeMillis() + 60 * 1000; // 60 seconds after now
  14.  
  15.                         Intent myCustomIntent = new Intent("MY.APPLICATION.WAKEUP.ACTION");
  16.  
  17.                         alarmService.set(AlarmManager.RTC_WAKEUP, timeToTrigger,
  18.  
  19.                                         myCustomIntent);
  20.  
  21.                 } catch (DeadObjectException e) {
  22.  
  23.                 }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


My code is untested, but looks good ;) Should work at least very similar...

Hope I could help you :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to General

Who is online

Users browsing this forum: No registered users and 4 guests