connection - Bluecove : restart bluetooth stack programmically -


i'm trying close bluetooth service, bluecove has bug on connection close method (https://code.google.com/p/bluecove/issues/detail?id=90) , trying workaround restart service. think restarting bluetoot stack solve problem. can programmically? i'am using microsoft bluetooth stack.

problem solved in way.

i restart application, firstly shut down bluecove manually.

bluecoveimpl.shutdown(); 

if restart application, bluecove shut down, cannot initialize bluetooth stack during start. here restart method:

public static void restartapplication(runnable runbeforerestart)         throws ioexception {     try     {         // java binary         string java = system.getproperty("java.home") + "/bin/java";         // vm arguments         list<string> vmarguments = managementfactory.getruntimemxbean()                 .getinputarguments();         stringbuffer vmargsoneline = new stringbuffer();         (string arg : vmarguments)         {             // if it's agent argument : ignore otherwise             // address of old application , new 1 in             // conflict             if (!arg.contains("-agentlib"))             {                 vmargsoneline.append(arg);                 vmargsoneline.append(" ");             }         }         // init command execute, add vm args         final stringbuffer cmd = new stringbuffer("\"" + java + "\" "                 + vmargsoneline);          // program main , program arguments         string[] maincommand = system.getproperty(sun_java_command).split(                 " ");         // program main jar         if (maincommand[0].endswith(".jar"))         {             // if it's jar, add -jar mainjar             cmd.append("-jar " + new file(maincommand[0]).getpath());         }         else         {             // else it's .class, add classpath , mainclass             cmd.append("-cp \"" + system.getproperty("java.class.path")                     + "\" " + maincommand[0]);         }         // add program arguments         (int = 1; < maincommand.length; i++)         {             cmd.append(" ");             cmd.append(maincommand[i]);         }          // execute command in shutdown hook, sure         // resources have been disposed before restarting application         runtime.getruntime().addshutdownhook(new thread() {             @override             public void run()             {                 try                 {                     runtime.getruntime().exec(cmd.tostring());                 }                 catch (ioexception e)                 {                     e.printstacktrace();                 }             }         });         // execute custom code before restarting         if (runbeforerestart != null)         {             runbeforerestart.run();         }         // @ first shut down bluecove manually         bluecoveimpl.shutdown();          system.exit(0);     }     catch (exception e)     {         // went wrong         throw new ioexception(                 "error while trying restart application", e);     } } 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

How to call a javascript function after the page loads with a chrome extension? -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -