/**
 * 
 */
package com.beem.project.beem;

import org.jivesoftware.smack.XMPPConnection;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.res.Resources;
import android.os.IBinder;
import android.widget.TextView;
import android.widget.Toast;

/**
 * @author darisk
 *
 */
public class BeemService extends Service {

    private NotificationManager notificationManager;

    private XMPPConnection connection;
    
    /* (non-Javadoc)
     * @see android.app.Service#onBind(android.content.Intent)
     */
    @Override
    public IBinder onBind(Intent arg0) {
	// TODO Auto-generated method stub
	return null;
    }
    
    private void showBasicNotification(int stringResource) {
	String text = (String) getText(stringResource);
	Notification notif = new Notification(R.drawable.logo, text, System.currentTimeMillis());
	notif.defaults = Notification.DEFAULT_ALL;
	notif.setLatestEventInfo(this, text, text, PendingIntent.getActivity(this, 0, new Intent(),0));
	notificationManager.notify(stringResource, notif);
	Toast toast = Toast.makeText(this, R.string.BeemServiceCreated, Toast.LENGTH_LONG);
	toast.show();
	
    }
    
    public void onCreate(){
	super.onCreate();
//	connection = new XMPPConnection("10.0.2.2"); // address du pc host de l'emulateur
	notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
	showBasicNotification(R.string.BeemServiceCreated);
    }
    
    public void onDestroy() {
	showBasicNotification(R.string.BeemServiceDestroyed); 
    }

}
