0

I am using Android market API

MarketSession session = new MarketSession();
        session.setAuthSubToken(token);
        session.getContext().setAndroidId( Settings.Secure.getString(getContentResolver(),
                            "android_id"));


        String query = "map";
        AppsRequest appsRequest = AppsRequest.newBuilder().setQuery(query)
                .setStartIndex(0).setStartIndex(0).setEntriesCount(10)
                .setWithExtendedInfo(true).build();

        session.append(appsRequest, new Callback<AppsResponse>() {
            @Override
            public void onResult(ResponseContext context,
                    AppsResponse response) {

                Debug.e("", "Total App: " + response.getAppList().size());

                for (int i = 0; i < response.getAppCount(); i++) {
                    Debug.e("", "" + response.getApp(i).getTitle());
                }

            }
        });

        session.flush();

My logcat

04-03 15:35:44.748: W/System.err(28330): Caused by: java.lang.RuntimeException: Response code = 400, msg = Bad Request

It's issue of setAndroidId because if I am using dead000beef as Android is then it works and above Android id (my galaxy s3 android id) does not work.

Is it android id actually?

halfer
  • 19,824
  • 17
  • 99
  • 186
Bhavesh Hirpara
  • 22,255
  • 15
  • 63
  • 104
  • This way is not effective. It is not an official API and it's developers can change or update several time, therefore you will need change your code or approach several time. I created an app with this unofficial API, first time it worked well, then after 1 month crashed, and again became working, then crashed again. And this API can retrieve information not about all applications on the Market. I think that the developers have their own database and they update it when they want. I decided to do not use this API. – Daryn Nov 22 '13 at 09:43

1 Answers1

1

You are using a wrong android id , this way worked for me

    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String udid = telephonyManager.getDeviceId();
    session = new MarketSession();
    session.getContext().setAndroidId(udid);
    session.setAuthSubToken(token);

Don't forget to add this permission

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
delshaer
  • 11
  • 3