How to disable the Android dialog of "application has stopped"?

Hi Xamazonian,

I have a foreground service that periodically get stopped by android and I would get a popup dialog of "ApplicationXYZ has stopped" with an OK button. Since this is a sticky foreground service, it will be restarted automatically. Is there a way for me to suppress this notification dialog?

I have tried to catch the global uncaught exception in the OnCreate of the service, but it is not being triggered.

public override void OnCreate()
{
try
{
base.OnCreate();
Logger.Debug("Started");

            //added 09/24 to trap and report all Unhandled exception.
            //This global catch for unhandled exception is not being trigger.  use try/catch instead.
            //var domain = AppDomain.CurrentDomain;

            //domain.UnhandledException += (sender, args) =>
            //{
            //    Logger.Error("*** UNHANDLED EXCEPTION OCCURRED ***");
            //    var ex = (Exception)args.ExceptionObject;
            //    if (ex != null)
            //    {
            //        Logger.Error(String.Format("IsTerminating = {0}", args.IsTerminating));
            //        Logger.Error(ex.Message, ex);
            //        var innerEx = ex.InnerException;
            //        while (innerEx != null)
            //        {
            //            Logger.Error(innerEx.Message, innerEx);
            //            innerEx = innerEx.InnerException;
            //        }
            //    }

            //};

            var startedIntent = new Intent("Constants.DroidMessageServiceStarted");
            SendBroadcast(startedIntent);
            var pendingIntent = PendingIntent.GetActivity(this, 1, startedIntent, PendingIntentFlags.UpdateCurrent);
            //this works except for in Debug mode (still getting killed, ticket opened)
            //var pendingIntent = PendingIntent.GetActivity(this, 0, startedIntent, PendingIntentFlags.CancelCurrent); //service get killed still
            //var pendingIntent = PendingIntent.GetActivity(this, 1, startedIntent, 0); //this does not work in either for foreground service.
            //var pendingIntent = PendingIntent.GetActivity(this, 0, startedIntent, PendingIntentFlags.UpdateCurrent); //service get killed still

            //create the notification 
            _msgNotificationBuilder = new Notification.Builder(this)
                .SetSmallIcon(Resource.Drawable.ic_messaging_service_wht)
                .SetContentTitle(NotificationDisplayTitle)
                .SetContentIntent(pendingIntent);

            Logger.Debug("Starting up DroidMessageService...");
            StartForeground(Conway.Core.Constants.DroidMessageAppId, _msgNotificationBuilder.Build());

            //TODO: TO DEBUG CONNECTION ISSUES
            //Java.Util.Logging.Logger logger = Java.Util.Logging.Logger.GetLogger("com.kaazing.gateway.jms.client");
            //logger.Level = Level.Fine;


            Logger.Debug("Finished");
        }
        catch (Exception e)
        {
            Logger.Error(e.StackTrace);
            throw;
        }

    }

any other ideas?

Thanks!
Jenny

Sign In or Register to comment.