Ok ,thank you , I got it to work. Just one more thing : Android doesn't ask for permission each time the device is connected now but it does always start my application . Can this be prevented ? My app does not need to be started each time the device is connected