# HG changeset patch # User Da Risk # Date 1237332240 -3600 # Node ID afd3a080d3185076389174b1ef352563d0be4b6e # Parent da30cff7f9ce32eb89c53ee95cbbebc8e0fb4108 On a un service qui se lance. Il faut maintenant lui faire effectuer une connexion XMPP diff -r da30cff7f9ce -r afd3a080d318 AndroidManifest.xml --- a/AndroidManifest.xml Tue Mar 17 22:02:07 2009 +0100 +++ b/AndroidManifest.xml Wed Mar 18 00:24:00 2009 +0100 @@ -11,6 +11,12 @@ - + + + + + + + diff -r da30cff7f9ce -r afd3a080d318 res/values/strings.xml --- a/res/values/strings.xml Tue Mar 17 22:02:07 2009 +0100 +++ b/res/values/strings.xml Wed Mar 18 00:24:00 2009 +0100 @@ -2,4 +2,7 @@ Beem +Use the Beem Service +BeemService Created +BeemService destroyed diff -r da30cff7f9ce -r afd3a080d318 src/com/beem/project/beem/Beem.java --- a/src/com/beem/project/beem/Beem.java Tue Mar 17 22:02:07 2009 +0100 +++ b/src/com/beem/project/beem/Beem.java Wed Mar 18 00:24:00 2009 +0100 @@ -1,37 +1,45 @@ package com.beem.project.beem; import android.app.Activity; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; import android.widget.EditText; public class Beem extends Activity { -<<<<<<< local /** Called when the activity is first created. * @param savedInstanceState toto */ -======= public static final String jabberSettings = "Beem"; private SharedPreferences mSettings; /** * Called when the activity is first created. */ ->>>>>>> other @Override public void onCreate(Bundle savedInstanceState) { -<<<<<<< local - super.onCreate(savedInstanceState); - setContentView(R.layout.main); -======= super.onCreate(savedInstanceState); setContentView(R.layout.main); - mSettings = getSharedPreferences(jabberSettings, MODE_PRIVATE); showJID(); ->>>>>>> other + Button btConnection = (Button) findViewById(R.id.connection); + btConnection.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + // TODO Auto-generated method stub + startService(new Intent(Beem.this,BeemService.class)); + + } + + + + }); } diff -r da30cff7f9ce -r afd3a080d318 src/com/beem/project/beem/BeemService.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/BeemService.java Wed Mar 18 00:24:00 2009 +0100 @@ -0,0 +1,59 @@ +/** + * + */ +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); + } + +} diff -r da30cff7f9ce -r afd3a080d318 src/com/beem/project/beem/service/IXMPPFacade.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/IXMPPFacade.aidl Wed Mar 18 00:24:00 2009 +0100 @@ -0,0 +1,11 @@ +package com.beem.project.beem.service; + +// import org.jivesoftware.smack.XMPPConnection; + +interface IXMPPFacade { + + // org.jivesoftware.smack.XMPPConnection getXMPPConnection(); + + List getContactList(); + +}