19. Binding the Service from Activity
public class TrainingActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate();
Intent intent = new Intent(this, RunningSessionService.class);
bindService(intent, sessionConnection, BIND_AUTO_CREATE);
}
@Override
protected void onDestroy() {
unbindService(sessionConnection);
super.onDestroy();
}
private ServiceConnection sessionConnection = new ServiceConnection() {
public void onServiceDisconnected(ComponentName name) {}
public void onServiceConnected(ComponentName name, IBinder serviceBinding) {
RunningSessionService.SessionBinder binding = (RunningSessionService.SessionBinder) serviceBinding;
session = binding.getService();
}
};
public void onStartTrackingClicked() {
if (session != null) {
session.startTracking();
}
}
}
20. Binding the Service from Activity
public class RunningSessionService extends Service {
@Override
public void onCreate() {
super.onCreate();
init();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {}
@Override
public void onDestroy() {}
@Override
public IBinder onBind(Intent intent) {
binding = new SessionBinder(this);
return binding;
}
@Override
public boolean onUnbind(Intent intent) {
stopSelf();
return super.onUnbind(intent);
}
public void startTracking() {
...
}
public void stopTracking() {
...
}
}
21. Intent
• An "intention" to do some work:
• Broadcast a message
• Start a Service
• Launch an Activity
• Display a web page or a list of contacts
• dial a phone nr. or answer a call
• etc.
28. Publishing to the Market
1. Sign up at https://market.android.com/publish
- 25$ fee
2. Prepare your application Package
- Test it
- Build it
- Sign it
3. Upload promotional material
4. Publish
29. Questions?
Anton Narusberg
anton@cannedapps.com
@antonnarusberg