New Collect Android Device's Primary Email Address through Apps By Patricbensen

New Collect Android Device's Primary Email Address through Apps By Patricbensen - is the information you are looking for, and in the blog All Specs Gadget we have provided her, all right in this article titled New Collect Android Device's Primary Email Address through Apps By Patricbensen we will discuss it in full, in addition to the information we have also provided a lot of info about the latest gadgets and a wide range of tips and tricks that according to the gadget you are using, well please continue reading:

Articles: New Collect Android Device's Primary Email Address through Apps By Patricbensen
Full Link : New Collect Android Device's Primary Email Address through Apps By Patricbensen
Artikel android, Artikel android 2.2, Artikel android 2.3, Artikel android developer, Artikel android device, Artikel android operating system, Artikel android sdk, Artikel android update, Artikel best android apps, Artikel google android, Artikel google play, Artikel latest android, Artikel what is android,

You can also see our article on:


New Collect Android Device's Primary Email Address through Apps By Patricbensen

If you are running a service or a third party app and wish to build an email list, these tips will help you do so. Whether it is for marketing purpose or for an advertising, you can look for an android user's email information smartly.

Every android phone has primary email id associated with the owner of the phone. Giving away email address for any good purpose may not be a big deal for users as far as it is asked in a legitimate way.

Android operating systems above 2.0 support for multiple email address whereas older OS has support for only one email. Using these APIs an android developer can easily pull the email information through apps and use them wisely.

Using AccountManager (API level 5+)

One can use AccountManager.getAccounts or AccountManager.getAccountsByType to get a list of all emails associated with the particular device.

For this app requires GET_ACCOUNTS permission.

Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
Account[] accounts = AccountManager.get(context).getAccounts();
for (Account account : accounts) {
    if (emailPattern.matcher(account.name).matches()) {
        String possibleEmail = account.name;
        ...
    }
}
code credits and source: stackoverflow discussion board

Using ContactsContact.Profile (API level 14+)

In Google Android ICS, 4.0, one can get user's email address through their profile. Using CursorLoader you can achieve this.

For this app requires READ_PROFILE and READ_CONTACTS permission.

Using Android's (ICS, 4.0) AccountPicker

Your app may need Google Play Services included but not request for any permissions.

The basic code snippets are as follows.

private static final int REQUEST_CODE_EMAIL = 1;
    private TextView email = (TextView) findViewById(R.id.email);

    // ...


    try {

        Intent intent = AccountPicker.newChooseAccountIntent(null, null,
                new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, false, null, null, null, null);
        startActivityForResult(intent, REQUEST_CODE_EMAIL);
    } catch (ActivityNotFoundException e) {
        // TODO
    }

    // ...


    @Override

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == REQUEST_CODE_EMAIL && resultCode == RESULT_OK) {
            String accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
            email.setText(accountName);
        }
    }
code credits and source: stackoverflow discussion board

Using AccountManager to construct Gmail address with the same username.

You will need below basic snippets

AccountManager manager = (AccountManager) getSystemService(ACCOUNT_SERVICE);
Account[] list = manager.getAccounts();

and ask for the permissions

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

Get Google Username

Using AccountManager.get(this) you can construct email address by collecting user's google username.

public String getUsername() {
    AccountManager manager = AccountManager.get(this);
    Account[] accounts = manager.getAccountsByType("com.google");
    List<String> possibleEmails = new LinkedList<String>();

    for (Account account : accounts) {

        // TODO: Check possibleEmail against an email regex or treat
        // account.name as an email address only for certain account.type
        // values.
        possibleEmails.add(account.name);
    }

    if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) {

        String email = possibleEmails.get(0);
        String[] parts = email.split("@");
        if (parts.length > 0 && parts[0] != null)
            return parts[0];
        else
            return null;
    } else
        return null;
}
code credits and source: stackoverflow discussion board

Get username through Gmail ID

accounts = AccountManager.get(this).getAccounts();
    Log.e("", "Size: " + accounts.length);
    for (Account account : accounts) {

        String possibleEmail = account.name;

        String type = account.type;

        if (type.equals("com.google")) {

            strGmail = possibleEmail;

            Log.e("", "Emails: " + strGmail);

            break;
        }
    }

Permissions needed - 

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

code credits and source: stackoverflow discussion board 

Collecting Google User Profile Details 

You can also collect user's account profile details by simply using AccountUtils.java codes, head to gist.github.com article here

Note: All codes and snippets are for tracking and educational purpose only. We are not responsible for any data loss or misuse.


Information New Collect Android Device's Primary Email Address through Apps By Patricbensen has finished we discussed

says the article New Collect Android Device's Primary Email Address through Apps By Patricbensen, we beharap be useful to you in finding repensi about the latest gadgets and long.

Information on New Collect Android Device's Primary Email Address through Apps By Patricbensen has finished you read this article and have the link https://patricbensen.blogspot.com/2016/07/new-collect-android-device-primary.html Hopefully the info we deliver is able to address the information needs of the present.

0 Response to "New Collect Android Device's Primary Email Address through Apps By Patricbensen"

Post a Comment