• Home
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • App Market Developer Platform
  • Clover GO
  • Ideas & Feedback
  • Semi-Integration
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
Skip to main content
  • Create
    • Ask a question
    • Post an idea
    • App Market Developer Platform
    • Clover GO
    • Ideas & Feedback
    • Semi-Integration
    • Topics
    • Questions
    • Articles
    • Ideas
  • Sign in
  • Home
  • App Market Developer Platform
This question was closed Apr 02 at 09:46 PM by Clover_Community_Bot for the following reason: automated

question

Vadzim avatar image
Vadzim asked · Nov 18, 2015 at 03:11 PM

"Activity ... has leaked ServiceConnection" exception on android

If I set my applicationId in gradle to something that does not start with com.clover I get "Activity has leaked ServiceConnection" when I try to do orderConnector.connect();

com.clover.abcdef works, com.abcdef does not.

How to reproduce:

  1. Take modifyorderbutton example from clover/android-examples repository
  2. Add this line to android module in app's build.gradle: defaultConfig { applicationId "com.abc" }
  3. Launch application, press the 'Add discount' button, you will see this exception in logs, and order will not be changed.

I can't attach full log as a file, so I will add short version here:

11-18 15:24:13.156 29977-29977/com.abc E/ActivityThread: Activity com.clover.example.modifyorder.app.AddDiscountActivity has leaked ServiceConnection com.clover.sdk.v3.order.OrderConnector@52801948 that was originally bound here

11-18 15:24:13.156 29977-29977/com.abc E/ActivityThread: android.app.ServiceConnectionLeaked: Activity com.clover.example.modifyorder.app.AddDiscountActivity has leaked ServiceConnection com.clover.sdk.v3.order.OrderConnector@52801948 that was originally bound here

...

com.clover.sdk.v1.ServiceConnector.connect(ServiceConnector.java:119) 11-18 15:24:13.156 29977-29977/com.abc E/ActivityThread: at com.clover.example.modifyorder.app.AddDiscountActivity$2.doInBackground(AddDiscountActivity.java:50)

Comment
0
10 |2000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

2 Answers

  • Sort by Created Created
  • Sort by Oldest Oldest
  • Sort by Votes Votes
Kavin Kannan avatar image
Kavin Kannan answered · Apr 05, 2017 at 05:56 PM Locked

In my case, activity was trying to be finished when there was an active order connection.

So you may check if you have finish(); call somewhere. If you do, I'de suggest you to disconnect orders connector before you call finish() in your activity.

0 · Share
10 |2000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jacob Abrams avatar image
Jacob Abrams answered · Nov 18, 2015 at 06:40 PM Locked

I believe the leaked connection is a side effect of a security exception being thrown before the connection is closed. The example code would not leak if the connection was closed in a finallyclause which is a safer way to code this. Do you see anything else in the logs? 3rd party apps must register what permissions they require so the merchant can see it and approve it upon installation, please follow the steps in https://docs.clover.com/build/android... to setup permissions for your app. Apps that start with com.clover do not require this and will not have security a security exception, however only Clover is allowed to publish apps that start with com.clover.

0 · Share
10 |2000 characters needed characters left characters exceeded
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Toggle Comment visibility. Current Visibility: Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community

question details

No one has followed this question yet.

Answers Subscribe to Answers Answers and Comments Subscribe to Comments and Answers

Related Questions

Android OrderConnector cash payment 1 Answer

Clover Station provide any Flag when clover station goes in payment?? 1 Answer

Android application development for clover? 1 Answer

Accessing NFC hardware from my android code 1 Answer

How can i send email from my clover app ? 2 Answers

Answerhub Logo
  • About
  • ·
  • FAQ
  • ·
  • Privacy
  • ·
  • Copyright © 2010-19 DZone, Inc.