4

How to open inbox in our apps.

final String ACCOUNT_TYPE_GOOGLE = "com.google";
final String[] FEATURES_MAIL = {
        "service_mail"
};
AccountManager.get(this).getAccountsByTypeAndFeatures(ACCOUNT_TYPE_GOOGLE, FEATURES_MAIL,
        new AccountManagerCallback() {
            @Override
            public void run(AccountManagerFuture future) {
                Account[] accounts = null;
                try {
                    accounts = future.getResult();
                    if (accounts != null && accounts.length > 0) {
                        String selectedAccount = accounts[0].name;
                        queryLabels(selectedAccount);
                    }
Josh Lee
  • 171,072
  • 38
  • 269
  • 275
  • Does it have to be GMail? The usual way would be to use the SEND intent and then pick Gmail out of the list. – HannahMitt Aug 13 '13 at 12:09
  • Welcome to SO. Please read the [FAQ] about how to ask good questions. Tell us your link you mentioned plus what you mean by "not working". Do you get any error? If so show them to us by editing your question and paste the stack trace there. – WarrenFaith Aug 13 '13 at 12:10

1 Answers1

1

If you always want to open gmail, and sure that client has gmail application, you can use this to start gmail application, which has inbox as opening activity.

PackageManager manager = getPackageManager();
Intent i = manager.getLaunchIntentForPackage("com.google.android.gmail");
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
mamba4ever
  • 2,662
  • 4
  • 28
  • 46
  • thanks sir , but i want open inbox in app and with notification. send me proper code to this programm by sandeep kushwah –  Aug 13 '13 at 12:25