Okay for your information.
I have used class for a this BroadcatReceiver :
public class OnBootReceiverextends BroadcastReceiver
{
private static final String TAG="BootstrapService";
private BootstrapService mBootstrapService;
@Override
public void onReceive(Context context, Intent intent)
{
Log.d(TAG,"onReceive() ---ENTER---");
Log.d(TAG,"Intent ACTION: "+intent.getAction());
Log.d(TAG,"Intent CATEGORIES ...");
Set<String> catSet=intent.getCategories();
Iterator<String> it=catSet.iterator();
while (it.hasNext())
{
Log.d(TAG," "+it.next());
} // WHILE
Log.d(TAG,"Done.");
// This is broadcast once, after the system has finished booting.
if ( intent.getAction() == intent.ACTION_BOOT_COMPLETED )
{
mBootstrapService.AutostartService();
} // IF
Log.d(TAG,"onReceive() ---EXIT-----");
} // onReceive
} // OnBootReceiver
And beside my second class that is launched by the previous one :
import android.app.Service;
//Need the following import to get access to the app resources, since this
//class is in a sub-package.
import com.OrangeLabs.BootstrapService.R;
// @brief Main class for the BootstrapService Android service
public class BootstrapService extends Service
{
...
--> Is it correct 'cos i don't see the log information in logcat through DDMS ?
Furthermore i don't see my package running in the DDMS listing ?
(For information, the test with the OnBootReceiver is well working and is
well launched)
And finaly my AndroidManifest.xml file :
<?xml version="1.0" encoding="utf-8"?>
package="com.OrangeLabs.BootstrapService"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.net.wifi.WIFI_STATE_CHANGED" />
<application android:label="@string/app_name">
<receiver android:name=".OnBootReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<receiver android:name=".OnWifiReceiver">
<intent-filter>
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<service android:enabled="true" android:name=".BootstrapService" />
</application>
<uses-sdk android:minSdkVersion="3"></uses-sdk>
</manifest>
ps : another interesting link was :
http://groups.google.com/group/android-developers/browse_thread/thread/8a0ebc433e1351a3
Cordialement
Thierry GAYET
NextInnovation.org
+33(0)663.849.589
________________________________
De : Mark Murphy <[email protected]>
À : [email protected]
Envoyé le : Mercredi, 24 Juin 2009, 15h02mn 52s
Objet : Re: Re : [android-developers] Re: How to catch BOOT_COMPLETED_ACTION
from an IntentReceiver
GAYET Thierry wrote:
> First thanks for your quick reply. I have well found the code you told
> me about (OnBootReceiver).
>
> I have one more question 'cos i as i have said before i ma programming a
> service that i want to start when Android boot.
>
> My core class extends Service not BroadcastReceiver. So may i extend
> more than one time. I mean to extends Service and BroadcastReceiver. for
> the same class ?
>
> Maybe i need to add a public class OnBootReceiver extends
> BroadcastReceiver inside my service project ? But if so how to link this
> second class with the service one ?
BOOT_COMPLETED must be received by a <receiver> element for a
BroadcatReceiver. You have no choice in the matter.
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy
Android Development Wiki: http://wiki.andmob.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---