BroadcastReceiver and BOOT_COMPLETED problem

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

BroadcastReceiver and BOOT_COMPLETED problem

Postby MoSin » Fri Jun 19, 2009 4:09 pm

Hi all, I read pretty much all the intent receiver/broadcast receiver/boot_completed posts around here and I can't figure out what I'm doing wrong. I just want my receiver to start a service on boot that will listens to the gps. The OnReceive is never called and I'm not even sure if the boot_completed intent is broadcast... I looked in the logs but can't see anything related to that. Any help would be appreciated. Here is my stuff

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. import android.content.BroadcastReceiver;
  3.  
  4. import android.content.ComponentName;
  5.  
  6. import android.content.Context;
  7.  
  8. import android.content.Intent;
  9.  
  10.  
  11.  
  12. public class BootEventManager extends BroadcastReceiver {
  13.  
  14.  
  15.  
  16.          @Override
  17.  
  18.          public void onReceive(Context context, Intent intent) {
  19.  
  20.                  
  21.  
  22.                  if(intent.getAction()!=null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)){
  23.  
  24.                          ComponentName comp = new ComponentName(context.getPackageName(), GPSHandlerService.class.getName());
  25.  
  26.                          ComponentName service = context.startService(new Intent().setComponent(comp));
  27.  
  28.                          
  29.  
  30.                                          
  31.  
  32.          }
  33.  
  34.  
  35.  
  36. }
  37.  
  38.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


Manifest

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <application android:icon="@drawable/icon" android:label="@string/app_name">
  3.  
  4.        
  5.  
  6.         <activity android:label="@string/app_name" android:name="proto2">
  7.  
  8.             <intent-filter>
  9.  
  10.                 <action android:name="android.intent.action.MAIN" />
  11.  
  12.                 <category android:name="android.intent.category.LAUNCHER" />
  13.  
  14.             </intent-filter>
  15.  
  16.         </activity>
  17.  
  18.        
  19.  
  20.         <receiver android:name="BootEventManager">
  21.  
  22.                  <intent-filter>
  23.  
  24.                        <action android:name="android.intent.action.BOOT_COMPLETED" />
  25.  
  26.                        <category android:name="android.intent.category.HOME" />
  27.  
  28.                  </intent-filter>
  29.  
  30.         </receiver>
  31.  
  32.  
  33.  
  34.         <provider android:name="DataContentProvider" android:authorities="ap2.proto2"></provider>
  35.  
  36.                 <service android:label="GPSHandlerService" android:enabled="true" android:exported="false" android:name="GPSHandlerService"></service>
  37.  
  38.                
  39.  
  40. </application>
  41.  
  42.     <uses-sdk android:minSdkVersion="3" />
  43.  
  44.    
  45.  
  46.     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  47.  
  48.     <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
  49.  
  50.     <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  51.  
  52.     <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  53.  
  54.  
Parsed in 0.005 seconds, using GeSHi 1.0.8.4
MoSin
Freshman
Freshman
 
Posts: 2
Joined: Fri Jun 19, 2009 3:13 pm

Top

Postby nderraugh » Thu Jul 16, 2009 1:57 am

bump
nderraugh
Freshman
Freshman
 
Posts: 2
Joined: Thu Jul 16, 2009 1:56 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: No registered users and 8 guests