9 |
import android.content.Intent; |
import android.content.Intent; |
10 |
import android.content.SharedPreferences; |
import android.content.SharedPreferences; |
11 |
import android.content.SharedPreferences.Editor; |
import android.content.SharedPreferences.Editor; |
|
import android.net.Uri; |
|
12 |
import android.os.AsyncTask; |
import android.os.AsyncTask; |
13 |
import android.os.Bundle; |
import android.os.Bundle; |
14 |
import android.os.Handler; |
import android.os.Handler; |
21 |
import android.widget.Button; |
import android.widget.Button; |
22 |
import android.widget.Toast; |
import android.widget.Toast; |
23 |
|
|
24 |
|
import com.example.android.trivialdrivesample.util.IabHelper; |
25 |
|
import com.example.android.trivialdrivesample.util.IabResult; |
26 |
import com.nullwire.trace.ExceptionHandler; |
import com.nullwire.trace.ExceptionHandler; |
27 |
|
|
28 |
import dk.thoerup.androidutils.CheckUpdates; |
import dk.thoerup.androidutils.CheckUpdates; |
44 |
ListFavorites |
ListFavorites |
45 |
} |
} |
46 |
|
|
47 |
|
IabHelper mHelper; |
48 |
|
|
49 |
Handler handler = new Handler(); |
Handler handler = new Handler(); |
50 |
|
|
51 |
SharedPreferences prefs; |
SharedPreferences prefs; |
127 |
} |
} |
128 |
|
|
129 |
} |
} |
130 |
|
|
131 |
|
|
132 |
|
try { |
133 |
|
initBilling(); |
134 |
|
} catch (Exception e) { |
135 |
|
//Do nothing - just don't crash if billing failed to initialize |
136 |
|
} |
137 |
|
|
138 |
|
|
139 |
|
} |
140 |
|
|
141 |
|
private void initBilling() { |
142 |
|
String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAln3XRJzM8Eo/SSMBLzSOj9pLedftZrWONRLO9KC/BU1Bv0EK3PQhza1S6apS69fa300ZitKSB91WDkf88eW4VJq8txmq8W1J2x/WJCFRQnFaPP0pDgERo9EdEULH2ybsOape/7+ypqNaDWxuqBh4fQfAd+Qpgdz8E7y5ZNbIKqJnRn2gyEfpzytiNQKNATI+XxJfyrS7urg/u/hXYw1R7VBNoAO7KU3b4D205WtXBn2u+Zexjd5disVGmZ5jd0BiuVOyPIWK5e9tA/VnKl/6XDfB9utCtXcAWFVUoVE6+8HWwo9ugFauuwYmbl6pTZydPKjyh9WxVR5MS2TPue/wEwIDAQAB"; |
143 |
|
|
144 |
|
// compute your public key and store it in base64EncodedPublicKey |
145 |
|
mHelper = new IabHelper(this, base64EncodedPublicKey); |
146 |
|
mHelper.enableDebugLogging(true); |
147 |
|
|
148 |
|
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() { |
149 |
|
public void onIabSetupFinished(IabResult result) { |
150 |
|
|
151 |
|
Log.d("TrainInfo", "onIabSetupFinished"); |
152 |
|
|
153 |
|
if (!result.isSuccess()) { |
154 |
|
// Oh noes, there was a problem. |
155 |
|
Log.d("TrainInfo", "Problem setting up In-app Billing: " + result); |
156 |
|
} |
157 |
|
// Hooray, IAB is fully set up! |
158 |
|
} |
159 |
|
}); |
160 |
|
|
161 |
} |
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
@Override |
@Override |
166 |
protected void onDestroy() { |
protected void onDestroy() { |
167 |
super.onDestroy(); |
super.onDestroy(); |
168 |
if (stationLoader != null) { |
if (stationLoader != null) { |
169 |
stationLoader.cancel(true); |
stationLoader.cancel(true); |
170 |
|
stationLoader = null; |
171 |
} |
} |
172 |
|
if (mHelper != null) { |
173 |
|
try { |
174 |
|
mHelper.dispose(); |
175 |
|
} catch (Exception e) { |
176 |
|
//Do Nothing |
177 |
|
} |
178 |
|
mHelper = null; |
179 |
|
} |
180 |
|
|
181 |
|
|
182 |
ProviderFactory.purgeOldEntries(); //exiting application, do some cleanup |
ProviderFactory.purgeOldEntries(); //exiting application, do some cleanup |
183 |
} |
} |