/[projects]/android/TrainInfo/src/dk/thoerup/traininfo/WelcomeScreen.java
ViewVC logotype

Diff of /android/TrainInfo/src/dk/thoerup/traininfo/WelcomeScreen.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2122 by torben, Mon Mar 12 09:27:14 2012 UTC revision 2123 by torben, Wed Mar 5 12:11:16 2014 UTC
# Line 9  import android.app.ProgressDialog; Line 9  import android.app.ProgressDialog;
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;
# Line 22  import android.view.Window; Line 21  import android.view.Window;
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;
# Line 43  public class WelcomeScreen extends Activ Line 44  public class WelcomeScreen extends Activ
44                  ListFavorites                  ListFavorites
45          }          }
46                    
47            IabHelper mHelper;
48            
49          Handler handler = new Handler();          Handler handler = new Handler();
50                    
51          SharedPreferences prefs;          SharedPreferences prefs;
# Line 124  public class WelcomeScreen extends Activ Line 127  public class WelcomeScreen extends Activ
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          }          }

Legend:
Removed from v.2122  
changed lines
  Added in v.2123

  ViewVC Help
Powered by ViewVC 1.1.20