diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/org/connectbot/service/ConnectionNotifier.java | 29 | 
1 files changed, 27 insertions, 2 deletions
diff --git a/src/org/connectbot/service/ConnectionNotifier.java b/src/org/connectbot/service/ConnectionNotifier.java index a9c054d..ffe2230 100644 --- a/src/org/connectbot/service/ConnectionNotifier.java +++ b/src/org/connectbot/service/ConnectionNotifier.java @@ -17,6 +17,9 @@  package org.connectbot.service; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +  import org.connectbot.ConsoleActivity;  import org.connectbot.R;  import org.connectbot.bean.HostBean; @@ -128,19 +131,41 @@ public abstract class ConnectionNotifier {  	public abstract void hideRunningNotification(Service context);  	private static class PreEclair extends ConnectionNotifier { +		private static final Class<?>[] setForegroundSignature = new Class[] {boolean.class}; +		private Method setForeground = null; +  		private static class Holder {  			private static final PreEclair sInstance = new PreEclair();  		} +		public PreEclair() { +			try { +				setForeground = Service.class.getMethod("setForeground", setForegroundSignature); +			} catch (Exception e) { +			} +		} +  		@Override  		public void showRunningNotification(Service context) { -			context.setForeground(true); +			Object[] setForegroundArgs = new Object[1]; +			setForegroundArgs[0] = Boolean.TRUE; +			try { +				setForeground.invoke(context, setForegroundArgs); +		    } catch (InvocationTargetException e) { +		    } catch (IllegalAccessException e) { +		    }  			getNotificationManager(context).notify(ONLINE_NOTIFICATION, newRunningNotification(context));  		}  		@Override  		public void hideRunningNotification(Service context) { -			context.setForeground(false); +			Object[] setForegroundArgs = new Object[1]; +			setForegroundArgs[0] = Boolean.FALSE; +			try { +				setForeground.invoke(context, setForegroundArgs); +		    } catch (InvocationTargetException e) { +		    } catch (IllegalAccessException e) { +		    }  			getNotificationManager(context).cancel(ONLINE_NOTIFICATION);  		}  	}  | 
