1
0
mirror of https://github.com/moparisthebest/SSLDroid synced 2024-11-23 17:32:15 -05:00

Moved notification creation and deletion to separate functions

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-04-15 08:43:13 +02:00
parent c1a7c94be9
commit 02465d3450

View File

@ -20,7 +20,7 @@ public class SSLDroid extends Service {
String keyPass = "titkos"; String keyPass = "titkos";
//Toast.makeText(this, "SSLDroid Service Started", Toast.LENGTH_LONG).show(); //Toast.makeText(this, "SSLDroid Service Started", Toast.LENGTH_LONG).show();
createNotification("SSLDroid is running", "SSLDroid service is running"); createNotification(0, "SSLDroid is running", "SSLDroid service is running");
Log.d(TAG, "SSLDroid Service Started"); Log.d(TAG, "SSLDroid Service Started");
//createNotification("test", "This is a test of the emergency broadcast system"); //createNotification("test", "This is a test of the emergency broadcast system");
@ -47,15 +47,19 @@ public class SSLDroid extends Service {
public void onDestroy() { public void onDestroy() {
try { try {
tp.stop(); tp.stop();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); removeNotification(0);
notificationManager.cancel(0);
Log.d(TAG, "SSLDroid Service Stopped"); Log.d(TAG, "SSLDroid Service Stopped");
} catch (Exception e) { } catch (Exception e) {
Log.d("SSLDroid", "Error stopping service: " + e.toString()); Log.d("SSLDroid", "Error stopping service: " + e.toString());
} }
} }
public void createNotification(String title, String text) { public void removeNotification(int id){
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.cancel(id);
}
public void createNotification(int id, String title, String text) {
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, Notification notification = new Notification(R.drawable.icon,
"SSLDroid startup", System.currentTimeMillis()); "SSLDroid startup", System.currentTimeMillis());
@ -65,18 +69,6 @@ public class SSLDroid extends Service {
Intent intent = new Intent(this, SSLDroidGui.class); Intent intent = new Intent(this, SSLDroidGui.class);
PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0); PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);
notification.setLatestEventInfo(this, title, text, activity); notification.setLatestEventInfo(this, title, text, activity);
notificationManager.notify(0, notification); notificationManager.notify(id, notification);
} }
} }
/*
public class MyStartupIntentReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
}
Intent serviceIntent = new Intent();
serviceIntent.setAction("hu.blint.ssldroid");
context.startService(serviceIntent);
}
*/