title: How do I use the unofficial Android Market API?
body: <p>I'm trying the sample code from <a href="http://code.google.com/p/android-market-api/wiki/HowToSearchApps" rel="nofollow noreferrer"><code>here</code></a>. But my app is crashing.</p>
  
  <p>I added logging and found out that it's crashing at <code>session.flush();</code> so I removed that line and it doesn't crash anymore.</p>
  
  <p>But it doesn't reach the <code>onResult</code> callback.</p>
  
  <pre><code>package com.mytest.app;
  
  import com.gc.android.market.api.MarketSession;
  import com.gc.android.market.api.MarketSession.Callback;
  import com.gc.android.market.api.model.Market.AppsRequest;
  import com.gc.android.market.api.model.Market.AppsResponse;
  import com.gc.android.market.api.model.Market.ResponseContext;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.provider.Settings.Secure;
  import android.util.Log;
  
  public class MarketAPITestActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Log.d("Market API", "Started");
  
          String email = "somebody@gmail.com";
          String pass = "mypass";
          String AndroidId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
  
          MarketSession session = new MarketSession();
          session.login(email,pass);
          session.getContext().setAndroidId(AndroidId);
  
          String query = "maps";
          AppsRequest appsRequest = AppsRequest.newBuilder()
                                          .setQuery(query)
                                          .setStartIndex(0).setEntriesCount(10)
                                          .setWithExtendedInfo(true)
                                          .build();
  
          session.append(appsRequest, new Callback&lt;AppsResponse&gt;() {
                   @Override
                   public void onResult(ResponseContext context, AppsResponse response) {
                          Log.d("Market API", "Got response");
                   }
          });
  
          session.flush();                        
      }
  }
  </code></pre>