diff options
| author | Andrew Dolgov <fox@madoka.volgo-balt.ru> | 2012-06-19 14:18:00 +0400 |
|---|---|---|
| committer | Andrew Dolgov <fox@madoka.volgo-balt.ru> | 2012-06-19 14:18:00 +0400 |
| commit | 08397a47af403d64a012a7961e7444254ccaa9a2 (patch) | |
| tree | ac3f0a2ad3a391fd60f2da3a69211d5f27c3a79b /src/org/fox/ttrss/billing/BillingService.java | |
| parent | 01151df966ed0006246790645b0f3e06c2ca94b8 (diff) | |
categorize source files
Diffstat (limited to 'src/org/fox/ttrss/billing/BillingService.java')
| -rw-r--r-- | src/org/fox/ttrss/billing/BillingService.java | 60 |
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) {
+
+ }
+
+}
|