summaryrefslogtreecommitdiff
path: root/src/org/fox/ttrss/BillingService.java
blob: e003df32aaeea64bce999412ee1458cb8b60956a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.fox.ttrss;

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) {
		
	}

}