Greetings,
I’m almost finished developing my Android app, however I’d like to be able to give the user the option to run it minimised in the background and be alerted whenever some event happens.
However, I don’t really know where to start. I’m trying to get an icon to show up on the status bar, to no avail. Essentially I’d like functionality similar to the ‘Trapster’ app where a little icon appears and the app notifies you when you’re approaching a speed camera!
Here’s the code I have sofar:
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;
public class Background extends Service{
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
super.onCreate();
Toast.makeText(this,"Service created ...", Toast.LENGTH_LONG).show();
}
@Override
public void onDestroy() {
super.onDestroy();
Toast.makeText(this, "Service destroyed ...", Toast.LENGTH_LONG).show();
}
}
Also, is it necessary to set some permission to use a service? Here’s what I have in my manifest file:
<uses-permission
android:name="android.permission.ACCESS_BACKGROUND_SERVICE" />
You’re on a good way, so far. Building what you need requires various steps :