Hi All,
I got how to run services in backgroud and foreground.. If anybody knows how to autostart any service please reply me... If you have sample code plz give me...
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"></uses-permission>
<receiver android:name=".OlympicsReceiver" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</receiver>public class OlympicsReceiver extends IntentReceiver
{
/* the intent source*/
static final String ACTION = "android.intent.action.BOOT_COMPLETED";
public void onReceiveIntent(Context context, Intent intent)
{
if (intent.getAction().equals(ACTION))
{
context.startService(new Intent(context,
OlympicsService.class), null);//start my your service here
Toast.makeText(context, "OlympicsReminder service has started!", Toast.LENGTH_LONG).show();
}
}
}



Users browsing this forum: No registered users and 0 guests