This is my code to access Google Drive, taken largely from ArtOfWarfare in this post:
public class MainActivity extends Activity {
class OnT
Try replacing this:
am.getAccounts()[0],
with this:
am.getAccountsByType("com.google")[0],
My code in the other topic was over simplified to assume that the first account it found would be a Google Account (and so have a Google Drive). The code we actually used in the app checked to make sure it was a Google Account (and then performed further checks to make sure it was a company account, which is why I simplified the code to what I shared.)