Assuming i’ve a device signed in with 2 gmail account. A@gmail.com & B@gmail.com.
I’ve created a page to retrive all active gmail and allow the user to choose which to use.
However, after the user decide which email to use, what should i do to the selected account?
Besides executing this following code, what else should i do?
Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0)); // boilerplate
registrationIntent.putExtra("sender", roleEmail);
startService(registrationIntent);
I also looked at the ChromeToPhone sample, based on their code, the selected account name was saved to the SharedPreferences which i don’t understand why.
You are getting the wrong email for that, you don’t use the users email for sending C2DM, you create a new gmail, then you use this together with a server and together with your app to send messages, not the users personal gmail. So in short 1 gmail for ALL users.
You should read this some more: https://developers.google.com/android/c2dm/