0

我正在研究一个需要访问 gmail 消息的 android 应用程序。我为这些东西创建了一个类,并从活动的 onCreate() 方法调用它。

消息框.java

   public void startConnection(String userName, String password) throws MessagingException {

            Properties properties = System.getProperties();
            properties.setProperty("mail.store.protocol", "imaps");
            properties.setProperty("mail.imaps.host","imaps.gmail.com");
            properties.setProperty("mail.imaps.quitwait", "false");
            properties.put("mail.imaps.auth", "true"); 
            properties.put("mail.imaps.port", "993"); 
            properties.put("mail.imaps.socketFactory.port", "993"); 
            properties.put("mail.imaps.socketFactory.class", 
                      "javax.net.ssl.SSLSocketFactory"); 
            properties.put("mail.imaps.socketFactory.fallback", "false"); 
            session = Session.getDefaultInstance(properties, null);

                store = session.getStore("imaps");
   **Problem in here**  store.connect("imap.gmail.com", userName, password);
        }

我的活动

       try  {
            messageBox.startConnection("username","password");

        } catch (MessagingException e) {
            e.printStackTrace();
        }

这里有什么问题?提前致谢

编辑:来自 LogCat

06-06 12:31:11.125: E/ThrottleService(289): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats: java.io.FileNotFoundException: /proc/net/xt_qtaguid/iface_stat_all: open failed: ENOENT (No such file or directory)
06-06 12:31:13.493: E/ActivityThread(653): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d085b0 that was originally bound here
06-06 12:31:13.493: E/ActivityThread(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d085b0 that was originally bound here
06-06 12:31:13.493: E/ActivityThread(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:31:13.493: E/ActivityThread(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:31:13.493: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:31:13.493: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:31:13.493: E/ActivityThread(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:31:13.493: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:31:13.493: E/ActivityThread(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:31:13.493: E/ActivityThread(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:31:13.493: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:31:13.493: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:31:13.493: E/ActivityThread(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:31:13.524: E/StrictMode(653): null
06-06 12:31:13.524: E/StrictMode(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d085b0 that was originally bound here
06-06 12:31:13.524: E/StrictMode(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:31:13.524: E/StrictMode(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:31:13.524: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:31:13.524: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:31:13.524: E/StrictMode(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:31:13.524: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:31:13.524: E/StrictMode(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:31:13.524: E/StrictMode(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:31:13.524: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:31:13.524: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:31:13.524: E/StrictMode(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:31:13.565: E/ActivityThread(653): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d080d8 that was originally bound here
06-06 12:31:13.565: E/ActivityThread(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d080d8 that was originally bound here
06-06 12:31:13.565: E/ActivityThread(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:31:13.565: E/ActivityThread(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:31:13.565: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:31:13.565: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:31:13.565: E/ActivityThread(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:31:13.565: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:31:13.565: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:31:13.565: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-06 12:31:13.565: E/ActivityThread(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-06 12:31:13.565: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:31:13.565: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:31:13.565: E/ActivityThread(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:31:13.565: E/ActivityThread(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:31:13.565: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:31:13.565: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:31:13.565: E/ActivityThread(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:31:13.613: E/StrictMode(653): null
06-06 12:31:13.613: E/StrictMode(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d080d8 that was originally bound here
06-06 12:31:13.613: E/StrictMode(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:31:13.613: E/StrictMode(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:31:13.613: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:31:13.613: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:31:13.613: E/StrictMode(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:31:13.613: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:31:13.613: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:31:13.613: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-06 12:31:13.613: E/StrictMode(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-06 12:31:13.613: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:31:13.613: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:31:13.613: E/StrictMode(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:31:13.613: E/StrictMode(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:31:13.613: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:31:13.613: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:31:13.613: E/StrictMode(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:32:03.693: E/ActivityThread(653): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d2ebc0 that was originally bound here
06-06 12:32:03.693: E/ActivityThread(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d2ebc0 that was originally bound here
06-06 12:32:03.693: E/ActivityThread(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:32:03.693: E/ActivityThread(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:32:03.693: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:32:03.693: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:32:03.693: E/ActivityThread(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:32:03.693: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:32:03.693: E/ActivityThread(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:32:03.693: E/ActivityThread(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:32:03.693: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:32:03.693: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:32:03.693: E/ActivityThread(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:32:03.863: E/StrictMode(653): null
06-06 12:32:03.863: E/StrictMode(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d2ebc0 that was originally bound here
06-06 12:32:03.863: E/StrictMode(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:32:03.863: E/StrictMode(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:32:03.863: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:32:03.863: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:32:03.863: E/StrictMode(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:32:03.863: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:32:03.863: E/StrictMode(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:32:03.863: E/StrictMode(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:32:03.863: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:32:03.863: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:32:03.863: E/StrictMode(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:32:03.933: E/ActivityThread(653): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d2e680 that was originally bound here
06-06 12:32:03.933: E/ActivityThread(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d2e680 that was originally bound here
06-06 12:32:03.933: E/ActivityThread(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:32:03.933: E/ActivityThread(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:32:03.933: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:32:03.933: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:32:03.933: E/ActivityThread(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:32:03.933: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:32:03.933: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:32:03.933: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-06 12:32:03.933: E/ActivityThread(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-06 12:32:03.933: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:32:03.933: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:32:03.933: E/ActivityThread(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:32:03.933: E/ActivityThread(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:32:03.933: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:32:03.933: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:32:03.933: E/ActivityThread(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:32:04.063: E/StrictMode(653): null
06-06 12:32:04.063: E/StrictMode(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d2e680 that was originally bound here
06-06 12:32:04.063: E/StrictMode(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:32:04.063: E/StrictMode(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:32:04.063: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:32:04.063: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:32:04.063: E/StrictMode(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:32:04.063: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:32:04.063: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:32:04.063: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-06 12:32:04.063: E/StrictMode(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-06 12:32:04.063: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:32:04.063: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:32:04.063: E/StrictMode(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:32:04.063: E/StrictMode(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:32:04.063: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:32:04.063: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:32:04.063: E/StrictMode(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:32:53.943: E/ActivityThread(653): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cef940 that was originally bound here
06-06 12:32:53.943: E/ActivityThread(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cef940 that was originally bound here
06-06 12:32:53.943: E/ActivityThread(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:32:53.943: E/ActivityThread(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:32:53.943: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:32:53.943: E/ActivityThread(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:32:53.943: E/ActivityThread(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:32:53.943: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:32:53.943: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:32:53.943: E/ActivityThread(653):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-06 12:32:53.943: E/ActivityThread(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-06 12:32:53.943: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:32:53.943: E/ActivityThread(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:32:53.943: E/ActivityThread(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:32:53.943: E/ActivityThread(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:32:53.943: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:32:53.943: E/ActivityThread(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:32:53.943: E/ActivityThread(653):  at java.lang.Thread.run(Thread.java:856)
06-06 12:32:53.963: E/StrictMode(653): null
06-06 12:32:53.963: E/StrictMode(653): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cef940 that was originally bound here
06-06 12:32:53.963: E/StrictMode(653):  at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-06 12:32:53.963: E/StrictMode(653):  at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-06 12:32:53.963: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-06 12:32:53.963: E/StrictMode(653):  at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-06 12:32:53.963: E/StrictMode(653):  at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-06 12:32:53.963: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-06 12:32:53.963: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-06 12:32:53.963: E/StrictMode(653):  at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-06 12:32:53.963: E/StrictMode(653):  at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-06 12:32:53.963: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-06 12:32:53.963: E/StrictMode(653):  at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-06 12:32:53.963: E/StrictMode(653):  at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-06 12:32:53.963: E/StrictMode(653):  at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-06 12:32:53.963: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-06 12:32:53.963: E/StrictMode(653):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-06 12:32:53.963: E/StrictMode(653):  at java.lang.Thread.run(Thread.java:856)
4

1 回答 1

1

在模拟器中禁用 Exchange 服务解决了这个错误:(使用 Settings->Apps->All->Exchange Services->Disable)

android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d085b0 that was originally bound here

由于使用 Android 4.2.2,我必须使用 AsyncTask 在活动中进行网络操作。这段代码对我有用:

public void MyActivity extends Activity{

public void onCreate(Bundle savedInstanceState){

     new  MyAsyncTaskClass().execute();
}

//internal class
public class MyAsyncTaskClass extends AsyncTask<Void, Void, Void>{

    @Override
    protected Void doInBackground(Void... arg0) {
            Properties properties = new Properties();
        properties.setProperty("mail.imaps.host", "imap.gmail.com"); 
            properties.setProperty("mail.imaps.auth", "true"); 
            properties.setProperty("mail.imaps.debug", "true"); 
            properties.setProperty("mail.imaps.port", "993");
            properties.setProperty("mail.store.protocol", "imaps");
        session = Session.getInstance(properties);

            store = session.getStore("imaps");
            store.connect("imap.gmail.com", 993, userName, password);
            return null;
      }

    }
}
于 2013-06-08T20:22:47.950 回答