How do I use the unofficial Android Market API?

后端 未结 3 1560
我在风中等你
我在风中等你 2021-01-02 10:24

I\'m trying the sample code from here. But my app is crashing.

I added logging and found out that it\'s crashing at session.flush(); so I removed that l

相关标签:
3条回答
  • 2021-01-02 10:45

    There is a problem with androidId. Instead of:

    String AndroidId = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID);
    

    Use this:

    String AndroidId = "dead000beef";
    

    It Works.

    0 讨论(0)
  • 2021-01-02 10:46

    I strongly suggest to take a look at https://groups.google.com/forum/#!forum/android-market-api (the only place I know still being active about Android Market API).

    Please take in account that the authentication method (login/pwd) is more than deprecated now (and not secure), and might not be anymore supported by the current market protocol.

    Also a valid android id is not anymore as simple as before to retreive, see the groups for that too.

    0 讨论(0)
  • 2021-01-02 10:48

    This is not Secure.ANDROID_ID, it's Gtalk service device ID.

    You can use the following code:

    public String getDeviceId(Context context) {
        String[] params = { GSERVICES_ID_KEY };
        Cursor c = context.getContentResolver()
                .query(GSERVICES_URI, null, null, params, null);
    
        if (!c.moveToFirst() || c.getColumnCount() < 2)
            return null;
    
        try {
            return Long.toHexString(Long.parseLong(c.getString(1))).toUpperCase();
        } catch (NumberFormatException e) {
            return null;
        }
    }
    

    And add the permission to read Gservice

    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    
    0 讨论(0)
提交回复
热议问题