In today’s modern ever changing world nothing stays forever, how your Android phone can be an exception, Right?
Android
is a vast Eco-system with wide verity of phones, whole different screen
sizes ranges from 4 inches phones to 6.5 inches phablet which hardly
fits in the pockets. up to 8 GB of RAM, Expandable storage and many
more…
Within
one year or two whole scenario of specs are changing in the phone and
they are so much tempting that one cannot resist them selves from
changing the phone and ended up with the new phone.
BUT wait what about all data in my old phone, Aaaah.
That’s not the problem at all. You can transfer them with wired way or wireless from old device to new device.
BUT
another big problem still persists which is the apps and their
credentials, which are very difficult to remember for some users.
No need to worry, Google at rescue.
Google has introduced a new way to transfer login or/and AUTH Tokens from your old phone to new phone.
Wait, what about my data security, What if some one stole my data.
Just
relax on that part because it transfers the credentials via a Bluetooth
connection or cable in encrypted connection without needing of data
connectivity. So your credentials will be safe in encrypted format and
transferred to your new device.
Developers have to make sure some things which are essential to make this transfer to work which is as follows.
The
lowest version which is supported is ICS (Ice cream Sandwich) and the
latest version is Oreo or higher. Latest version of Google play services
are also essential on both of the phones. And most important thing, app
must build APK using Google Play services SDK version 11.2.0 or higher
Your
App must provide authenticator for Account Manager. This will list your
app in the Android’s Account screen(Settings ->Accounts/User &
Accounts).
For adding the support of transferring custom account you must declare
START_ACCOUNT_EXPORT
broadcast receiver for authenticator service in your app’s manifest
Here comes the main part. For sending data from old phone to new phone add the following
AccountTransferClient client = AccountTransfer.getAccountTransferClient(this);
Task<Void> exportTask = client.sendData(ACCOUNT_TYPE, transferBytes);
try {
// Wait for the task to either complete or provide the callback.
Tasks.await(exportTask, TIMEOUT_API, TIME_UNIT);
} catch (ExecutionException | InterruptedException | TimeoutException e) {
client.notifyCompletion(ACCOUNT_TYPE,AuthenticatorTransferCompletionStatus.COMPLETED_FAILURE);
return;
}
On the target device the
ACTION_ACCOUNT_IMPORT_DATA_AVAILABLE
broadcast will received and developer need to handle that broadcast and start a service and call retrieveData()
AccountTransferClient client = AccountTransfer.getAccountTransferClient(this);
Task<Void> exportTask = client.retrieveData(ACCOUNT_TYPE);
try {
byte[] transferBytes = Tasks.await(transferTask, TIMEOUT_API, TIME_UNIT);
// Add the transferred account(s) to AccountManager to register it with the framework.
} catch (ExecutionException | InterruptedException | TimeoutException e) {
client.notifyCompletion(ACCOUNT_TYPE, AuthenticatorTransferCompletionStatus.COMPLETED_FAILURE);
return;
}
client.notifyCompletion(ACCOUNT_TYPE, AuthenticatorTransferCompletionStatus.COMPLETED_SUCCESS);
It’s not necessary that you will always get the success, but this is an awesome API provided by google for those who hates to re-login even after getting the new phone.
Here’s are some link which might be helpful to get the work done.
No comments:
Write comments