summaryrefslogtreecommitdiff
path: root/src/org/fox/ttrss/billing/BillingService.java
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2012-06-19 18:00:38 +0400
committerAndrew Dolgov <fox@fakecake.org>2012-06-19 18:00:38 +0400
commit82035f40035bf5fb72b24fe8cc38491ff5d7dfc6 (patch)
tree825ffbf2d98a311ee4ba4c5b1581afd28e9aeeb0 /src/org/fox/ttrss/billing/BillingService.java
parent299682bb6d4e2e9f2b0f0553f6f475f7f7585a99 (diff)
parentf01f0ab35831fefbee30a4ae587ae1edf5c1fe20 (diff)
Merge branch 'master' of github.com:gothfox/Tiny-Tiny-RSS-for-Honeycomb
Diffstat (limited to 'src/org/fox/ttrss/billing/BillingService.java')
-rw-r--r--src/org/fox/ttrss/billing/BillingService.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/org/fox/ttrss/billing/BillingService.java b/src/org/fox/ttrss/billing/BillingService.java
new file mode 100644
index 00000000..2ae53234
--- /dev/null
+++ b/src/org/fox/ttrss/billing/BillingService.java
@@ -0,0 +1,60 @@
+package org.fox.ttrss.billing;
+
+import android.app.Service;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.os.IBinder;
+import android.util.Log;
+
+import com.android.vending.billing.IMarketBillingService;
+
+public class BillingService extends Service implements ServiceConnection{
+
+ private static final String TAG = "BillingService";
+
+ /** The service connection to the remote MarketBillingService. */
+ private IMarketBillingService mService;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ Log.i(TAG, "Service starting with onCreate");
+
+ try {
+ boolean bindResult = bindService(new Intent("com.android.vending.billing.MarketBillingService.BIND"), this, Context.BIND_AUTO_CREATE);
+ if(bindResult){
+ Log.i(TAG,"Market Billing Service Successfully Bound");
+ } else {
+ Log.e(TAG,"Market Billing Service could not be bound.");
+ //TODO stop user continuing
+ }
+ } catch (SecurityException e){
+ Log.e(TAG,"Market Billing Service could not be bound. SecurityException: "+e);
+ //TODO stop user continuing
+ }
+ }
+
+ public void setContext(Context context) {
+ attachBaseContext(context);
+ }
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ Log.i(TAG, "Market Billing Service Connected.");
+ mService = IMarketBillingService.Stub.asInterface(service);
+ BillingHelper.instantiateHelper(getBaseContext(), mService);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName name) {
+
+ }
+
+}