In order to use my google-play-crawler project in an android application, you have two option to get it work :

  • requesting username, password and android-id from user, which is kind of lame! or
  • fetching android-id and authentication token, that google play application(aka Phonesky) uses, programmatically.

You can accomplish second option with these functions.

private String getAuthToken() throws OperationCanceledException, AuthenticatorException, IOException {
  Account account = AccountManager.get(this).getAccountsByType("")[0];
  AccountManagerFuture<Bundle> accFut = AccountManager.get(this).getAuthToken(account, "androidmarket", null, null, null, null);
  Bundle authTokenBundle = accFut.getResult();
  return authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString();
private String getAndroidID() {
  String[] query = new String[] { "android_id" };
  Cursor cursor = getApplicationContext().getContentResolver().query( Uri.parse("content://"), null, null, query, null);
  if ((cursor.moveToFirst()) && (cursor.getColumnCount() >= 2)) {
    return Long.toHexString(Long.parseLong(cursor.getString(1))).toUpperCase();
  return null;

To call these two functions, you need to grant these permissions in your manifest file.

  <uses-permission android:name="android.permission.GET_ACCOUNTS" />
  <uses-permission android:name= "android.permission.MANAGE_ACCOUNTS" />
  <uses-permission android:name="" />

Ali Demiroz

I am a software developer, life-long learner and time-pemitted gamer!

blog comments powered by Disqus