Correction du bug de l'activity sendim qui se ferme
authorDa Risk <darisk972@gmail.com>
Sat, 23 May 2009 16:56:49 +0200
changeset 221 d2c030543834
parent 220 2b8bebb95bbd
child 222 f72be51936d5
Correction du bug de l'activity sendim qui se ferme
src/com/beem/project/beem/service/BeemChatManager.java
src/com/beem/project/beem/ui/SendIM.java
--- a/src/com/beem/project/beem/service/BeemChatManager.java	Fri May 22 22:30:28 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java	Sat May 23 16:56:49 2009 +0200
@@ -172,7 +172,7 @@
 		notif.defaults = Notification.DEFAULT_ALL;
 		notif.flags = Notification.FLAG_AUTO_CANCEL;
 		Intent intent = new Intent(mService, SendIM.class);
-		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT| Intent.FLAG_ACTIVITY_SINGLE_TOP);
+		intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT| Intent.FLAG_ACTIVITY_SINGLE_TOP); 
 		// TODO use prefix for name
 		intent.putExtra("contact", chat.getParticipant());
 		notif.setLatestEventInfo(mService, text, mService.getString(R.string.BeemChatManagerNewMessage),
--- a/src/com/beem/project/beem/ui/SendIM.java	Fri May 22 22:30:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Sat May 23 16:56:49 2009 +0200
@@ -88,6 +88,7 @@
     @Override
     protected void onStart() {
 	super.onStart();
+	Log.i(TAG, "on start");
 	// TODO cancel the notification if any
 	if (mContact == null)
 	    mContact = getIntent().getParcelableExtra("contact");
@@ -98,20 +99,16 @@
 
     @Override
     protected void onNewIntent(Intent intent) {
-	// TODO Auto-generated method stub
 	super.onNewIntent(intent);
-	Contact c = intent.getParcelableExtra("contact");
-	try {
-	    switchChat(c);
-	} catch (RemoteException e) {
-	    Log.e(TAG, "Error durring switch chat", e);
-	}
+	mContact = intent.getParcelableExtra("contact");
 	setViewHeader();
+	Log.i(TAG, "new intent");
     }
 
     @Override
     protected void onResume() {
 	super.onResume();
+	Log.i(TAG, "resume");
 	mBeemApplication = BeemApplication.getApplication(this);
 	if (!mBeemApplication.isConnected())
 	    mBeemApplication.startBeemService();
@@ -121,8 +118,10 @@
 	    public void run() {
 		mService = mBeemApplication.getXmppFacade();
 		try {
-		    mChatManager = mService.getChatManager();
-		    mChatManager.addChatCreationListener(mChatManagerListener);
+		    if (mChatManager == null) {
+			mChatManager = mService.getChatManager();
+			mChatManager.addChatCreationListener(mChatManagerListener);
+		    }
 		    switchChat(mContact);
 		} catch (RemoteException e) {
 		    Log.e(TAG, "Error during chat manager creation", e);
@@ -133,19 +132,18 @@
 
     @Override
     protected void onPause() {
+	super.onPause();
 	Log.d(TAG, "onPause");
 	try {
 	    mChat.setOpen(false);
 	} catch (RemoteException e) {
 	    Log.d(TAG, "mchat open false", e);
 	}
-	super.onPause();
-	finish();
     }
 
     @Override
     protected void onStop() {
-	
+	super.onStop();
 	Log.d(TAG, "onStop");
 	try {
 	    mChat.setOpen(false);
@@ -153,12 +151,12 @@
 	    Log.d(TAG, "mchat open false", e);
 	}
 	mBeemApplication.unbindBeemService();
-	super.onStop();
     }
 
     @Override
     protected void onDestroy() {
-	
+	super.onDestroy();
+	Log.d(TAG, "onDestroy");
 	if (mChatManager != null) {
 	    try {
 		mChatManager.removeChatCreationListener(mChatManagerListener);
@@ -168,7 +166,6 @@
 		Log.e(TAG, "mchat manager and SendIM destroy", e);
 	    }
 	}
-	super.onDestroy();
     }
 
     /**