removes asynctask from service to avoid indeterminate loading screen when app starts

This commit is contained in:
tom79 2017-08-30 08:59:15 +02:00
parent 44b71dbbe6
commit 8e4f47b464
8 changed files with 155 additions and 225 deletions

View File

@ -26,7 +26,6 @@ import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
@ -64,13 +63,9 @@ import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Stack;
import java.util.concurrent.TimeUnit;
import fr.gouv.etalab.mastodon.asynctasks.StreamingUserAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
@ -141,9 +136,9 @@ public class MainActivity extends AppCompatActivity
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
StreamingUserAsyncTask.EventStreaming eventStreaming = (StreamingUserAsyncTask.EventStreaming) intent.getSerializableExtra("eventStreaming");
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
if( eventStreaming == StreamingUserAsyncTask.EventStreaming.NOTIFICATION){
if( eventStreaming == StreamingService.EventStreaming.NOTIFICATION){
Notification notification = b.getParcelable("data");
if(notificationsFragment != null){
if(notificationsFragment.getUserVisibleHint()){
@ -157,7 +152,7 @@ public class MainActivity extends AppCompatActivity
newNotif++;
updateNotifCounter();
}
}else if(eventStreaming == StreamingUserAsyncTask.EventStreaming.UPDATE){
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
Status status = b.getParcelable("data");
if( homeFragment != null){
if(homeFragment.getUserVisibleHint()){
@ -171,7 +166,7 @@ public class MainActivity extends AppCompatActivity
newHome++;
updateHomeCounter();
}
}else if(eventStreaming == StreamingUserAsyncTask.EventStreaming.DELETE){
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
String id = b.getString("id");
if(notificationsFragment != null) {
if (notificationsFragment.getUserVisibleHint()) {

View File

@ -16,8 +16,11 @@ package fr.gouv.etalab.mastodon.asynctasks;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface;
@ -80,7 +83,6 @@ public class RetrieveFeedsAsyncTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
API api = new API(context);
switch (action){
case HOME:

View File

@ -18,6 +18,7 @@ import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
import android.os.SystemClock;
import android.util.Log;
import com.evernote.android.job.JobManager;
import com.evernote.android.job.JobRequest;
@ -68,6 +69,7 @@ public class RetrieveScheduledTootsAsyncTask extends AsyncTask<Void, Void, Void>
}else{
jobIds = new int[]{};
}
if( storedStatuses != null && storedStatuses.size() > 0 ){
for(StoredStatus ss: storedStatuses){
if (!Helper.isJobPresent(jobIds, ss.getJobId())){

View File

@ -1,159 +0,0 @@
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastalab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.asynctasks;
import android.os.AsyncTask;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import javax.net.ssl.HttpsURLConnection;
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveStreamingInterface;
/**
* Created by Thomas on 28/08/2017.
* Calls user streaming api
*/
public class StreamingUserAsyncTask extends AsyncTask {
private String instance, token, acct, userId;
private OnRetrieveStreamingInterface listener;
private static HashMap<String, HttpURLConnection> connectionHashMap;
private EventStreaming lastEvent;
public StreamingUserAsyncTask(String instance, String token, String acct, String userId, OnRetrieveStreamingInterface onRetrieveStreamingInterface){
this.instance = instance;
this.token = token;
this.acct = acct;
this.userId = userId;
this.listener = onRetrieveStreamingInterface;
}
public enum EventStreaming{
UPDATE,
NOTIFICATION,
DELETE,
NONE
}
@Override
protected Object doInBackground(Object[] params){
if( connectionHashMap == null)
connectionHashMap = new HashMap<>();
boolean connectionAlive = false;
if( connectionHashMap.get(acct+userId) != null) {
try {
connectionAlive = (connectionHashMap.get(acct + userId).getResponseCode() == 200);
} catch (Exception e) {
connectionAlive = false;
}
}
if( !connectionAlive) {
try {
URL url = new URL("https://" + this.instance + "/api/v1/streaming/user");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setRequestProperty("Authorization", "Bearer " + this.token);
urlConnection.setRequestProperty("Connection", "Keep-Alive");
urlConnection.setRequestProperty("Keep-Alive", "header");
urlConnection.setSSLSocketFactory(new TLSSocketFactory());
connectionHashMap.put(acct+userId, urlConnection);
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
readStream(inputStream);
} catch (IOException | NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}
}
return null;
}
private String readStream(InputStream inputStream) {
BufferedReader reader = null;
try{
reader = new BufferedReader(new InputStreamReader(inputStream));
String event;
EventStreaming eventStreaming = null;
while((event = reader.readLine()) != null){
if( lastEvent == EventStreaming.NONE || lastEvent == null) {
switch (event.trim()) {
case "event: update":
lastEvent = EventStreaming.UPDATE;
break;
case "event: notification":
lastEvent = EventStreaming.NOTIFICATION;
break;
case "event: delete":
lastEvent = EventStreaming.DELETE;
break;
default:
lastEvent = EventStreaming.NONE;
}
}else{
event = event.replace("data: ","");
if(lastEvent == EventStreaming.UPDATE) {
eventStreaming = EventStreaming.UPDATE;
}else if(lastEvent == EventStreaming.NOTIFICATION) {
eventStreaming = EventStreaming.NOTIFICATION;
}else if( lastEvent == EventStreaming.DELETE) {
eventStreaming = EventStreaming.DELETE;
event = "{id:" + event + "}";
}
lastEvent = EventStreaming.NONE;
try {
JSONObject eventJson = new JSONObject(event);
listener.onRetrieveStreaming(eventStreaming, eventJson, acct, userId);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}catch (Exception e){
e.printStackTrace();
}finally {
if(reader != null){
try{
reader.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
return null;
}
}

View File

@ -25,6 +25,7 @@ import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.SwipeRefreshLayout;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -88,7 +89,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_status, container, false);
statuses = new ArrayList<>();
context = getContext();
@ -204,7 +204,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
R.color.mastodonC2,
R.color.mastodonC3);
if( type == RetrieveFeedsAsyncTask.Type.USER)
asyncTask = new RetrieveFeedsAsyncTask(context, type, targetedId, max_id, showMediaOnly, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
else if( type == RetrieveFeedsAsyncTask.Type.TAG)

View File

@ -1,28 +0,0 @@
/* Copyright 2017 Thomas Schneider
*
* This file is a part of Mastalab
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Mastalab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with Mastalab; if not,
* see <http://www.gnu.org/licenses>. */
package fr.gouv.etalab.mastodon.interfaces;
import org.json.JSONObject;
import fr.gouv.etalab.mastodon.asynctasks.StreamingUserAsyncTask;
/**
* Created by Thomas on 28/08/2017.
* Interface when event from streaming api has been retrieved
*/
public interface OnRetrieveStreamingInterface {
void onRetrieveStreaming(StreamingUserAsyncTask.EventStreaming event, JSONObject response, String acct, String userId);
}

View File

@ -22,7 +22,6 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
@ -44,18 +43,29 @@ import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListene
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.List;
import javax.net.ssl.HttpsURLConnection;
import fr.gouv.etalab.mastodon.activities.MainActivity;
import fr.gouv.etalab.mastodon.asynctasks.StreamingUserAsyncTask;
import fr.gouv.etalab.mastodon.client.API;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
import fr.gouv.etalab.mastodon.client.Entities.Status;
import fr.gouv.etalab.mastodon.client.PatchBaseImageDownloader;
import fr.gouv.etalab.mastodon.client.TLSSocketFactory;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveStreamingInterface;
import fr.gouv.etalab.mastodon.sqlite.AccountDAO;
import fr.gouv.etalab.mastodon.sqlite.Sqlite;
import mastodon.etalab.gouv.fr.mastodon.R;
@ -64,6 +74,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT;
import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID;
import static fr.gouv.etalab.mastodon.helper.Helper.canNotify;
import static fr.gouv.etalab.mastodon.helper.Helper.notify_user;
/**
@ -71,7 +82,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.notify_user;
* Manage service for streaming api and new notifications
*/
public class StreamingService extends Service implements OnRetrieveStreamingInterface {
public class StreamingService extends Service {
private String message;
private int notificationId;
@ -117,10 +128,118 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
if( accounts == null )
return;
//Retrieve users in db that owner has.
for (Account account: accounts) {
new StreamingUserAsyncTask(account.getInstance(), account.getToken(), account.getAcct(), account.getId(), StreamingService.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
for (final Account account: accounts) {
//new StreamingUserAsyncTask(account.getInstance(), account.getToken(), account.getAcct(), account.getId(), StreamingService.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
Thread readThread = new Thread(new Runnable() {
@Override
public void run() {
try {
proceeds(account);
} catch (Exception ignored) {
}
}
});
readThread.start();
}
}
}
private static HashMap<String, HttpURLConnection> connectionHashMap;
private EventStreaming lastEvent;
public enum EventStreaming{
UPDATE,
NOTIFICATION,
DELETE,
NONE
}
private void proceeds(Account account){
if( connectionHashMap == null)
connectionHashMap = new HashMap<>();
boolean connectionAlive = false;
if( connectionHashMap.get(account.getAcct()+account.getId()) != null) {
try {
connectionAlive = (connectionHashMap.get(account.getAcct()+account.getId()).getResponseCode() == 200);
} catch (Exception e) {
connectionAlive = false;
}
}
if( !connectionAlive) {
try {
URL url = new URL("https://" + account.getInstance() + "/api/v1/streaming/user");
HttpsURLConnection urlConnection = (HttpsURLConnection) url.openConnection();
urlConnection.setRequestProperty("Content-Type", "application/json");
urlConnection.setRequestProperty("Authorization", "Bearer " + account.getToken());
urlConnection.setRequestProperty("Connection", "Keep-Alive");
urlConnection.setRequestProperty("Keep-Alive", "header");
urlConnection.setSSLSocketFactory(new TLSSocketFactory());
connectionHashMap.put(account.getAcct()+account.getId(), urlConnection);
InputStream inputStream = new BufferedInputStream(urlConnection.getInputStream());
readStream(inputStream, account);
} catch (IOException | NoSuchAlgorithmException | KeyManagementException e) {
e.printStackTrace();
}
}
}
private String readStream(InputStream inputStream, Account account) {
BufferedReader reader = null;
try{
reader = new BufferedReader(new InputStreamReader(inputStream));
String event;
EventStreaming eventStreaming = null;
while((event = reader.readLine()) != null){
if( lastEvent == EventStreaming.NONE || lastEvent == null) {
switch (event.trim()) {
case "event: update":
lastEvent = EventStreaming.UPDATE;
break;
case "event: notification":
lastEvent = EventStreaming.NOTIFICATION;
break;
case "event: delete":
lastEvent = EventStreaming.DELETE;
break;
default:
lastEvent = EventStreaming.NONE;
}
}else{
event = event.replace("data: ","");
if(lastEvent == EventStreaming.UPDATE) {
eventStreaming = EventStreaming.UPDATE;
}else if(lastEvent == EventStreaming.NOTIFICATION) {
eventStreaming = EventStreaming.NOTIFICATION;
}else if( lastEvent == EventStreaming.DELETE) {
eventStreaming = EventStreaming.DELETE;
event = "{id:" + event + "}";
}
lastEvent = EventStreaming.NONE;
try {
JSONObject eventJson = new JSONObject(event);
onRetrieveStreaming(eventStreaming, eventJson, account.getAcct(), account.getId());
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}catch (Exception e){
e.printStackTrace();
}finally {
if(reader != null){
try{
reader.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
return null;
}
@Override
@ -133,8 +252,7 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
}
@Override
public void onRetrieveStreaming(StreamingUserAsyncTask.EventStreaming event, JSONObject response, String acct, String userId) {
public void onRetrieveStreaming(EventStreaming event, JSONObject response, String acct, String userId) {
if( response == null )
return;
String max_id_notif = null;
@ -153,7 +271,7 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
Status status = null;
Notification notification = null;
String dataId = null;
if( event == StreamingUserAsyncTask.EventStreaming.NOTIFICATION){
if( event == EventStreaming.NOTIFICATION){
notification = API.parseNotificationResponse(getApplicationContext(), response);
max_id_notif = notification.getId();
switch (notification.getType()){
@ -216,7 +334,7 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
message = "";
}
}else if ( event == StreamingUserAsyncTask.EventStreaming.UPDATE){
}else if ( event == EventStreaming.UPDATE){
status = API.parseStatuses(getApplicationContext(), response);
max_id_home = status.getId();
if( status.getContent() != null) {
@ -232,7 +350,7 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
}
title = getString(R.string.notif_pouet, status.getAccount().getUsername());
notificationUrl = status.getAccount().getAvatar();
}else if( event == StreamingUserAsyncTask.EventStreaming.DELETE){
}else if( event == EventStreaming.DELETE){
try {
dataId = response.getString("id");
@ -268,15 +386,15 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
Intent intentBC = new Intent(Helper.RECEIVE_DATA);
intentBC.putExtra("eventStreaming", event);
Bundle b = new Bundle();
if( event == StreamingUserAsyncTask.EventStreaming.UPDATE)
if( event == EventStreaming.UPDATE)
b.putParcelable("data", status);
else if(event == StreamingUserAsyncTask.EventStreaming.NOTIFICATION)
else if(event == EventStreaming.NOTIFICATION)
b.putParcelable("data", notification);
else if(event == StreamingUserAsyncTask.EventStreaming.DELETE)
else if(event == EventStreaming.DELETE)
b.putString("id", dataId);
intentBC.putExtras(b);
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(intentBC);
}else if(event == StreamingUserAsyncTask.EventStreaming.NOTIFICATION ){
}else if(event == EventStreaming.NOTIFICATION ){
notify = true;
intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK );
@ -288,7 +406,7 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
editor.putString(Helper.LAST_NOTIFICATION_MAX_ID + userId, notification.getId());
editor.apply();
}else if(event == StreamingUserAsyncTask.EventStreaming.UPDATE ){
}else if(event == EventStreaming.UPDATE ){
//lastePreviousContent contains the content of the last notification, if it was a mention it will avoid to push two notifications
if( account == null || (lastePreviousContent != null && lastePreviousContent.equals(status.getContent()))) { //troubles when getting the account
@ -304,6 +422,9 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
break;
}
}
//Here we check if the user wants home timeline notifications
notify = sharedpreferences.getBoolean(Helper.SET_NOTIF_HOMETIMELINE, true);
if( notify) {
intent = new Intent(getApplicationContext(), MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
@ -317,6 +438,9 @@ public class StreamingService extends Service implements OnRetrieveStreamingInte
}
}
}
//All is good here for a notification, we will know check if it can be done depending of the hour
if( notify)
notify = canNotify(getApplicationContext());
if( notify){
if( notificationUrl != null){
ImageLoader imageLoaderNoty = ImageLoader.getInstance();

View File

@ -26,7 +26,6 @@ import android.graphics.PorterDuff;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.TabLayout;
@ -38,8 +37,6 @@ import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.SwitchCompat;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.support.design.widget.NavigationView;
@ -68,13 +65,10 @@ import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import java.util.Stack;
import java.util.concurrent.TimeUnit;
import fr.gouv.etalab.mastodon.asynctasks.StreamingUserAsyncTask;
import fr.gouv.etalab.mastodon.asynctasks.UpdateAccountInfoByIDAsyncTask;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Notification;
@ -147,8 +141,8 @@ public class MainActivity extends AppCompatActivity
@Override
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
StreamingUserAsyncTask.EventStreaming eventStreaming = (StreamingUserAsyncTask.EventStreaming) intent.getSerializableExtra("eventStreaming");
if( eventStreaming == StreamingUserAsyncTask.EventStreaming.NOTIFICATION){
StreamingService.EventStreaming eventStreaming = (StreamingService.EventStreaming) intent.getSerializableExtra("eventStreaming");
if( eventStreaming == StreamingService.EventStreaming.NOTIFICATION){
Notification notification = b.getParcelable("data");
if(notificationsFragment != null){
if(notificationsFragment.getUserVisibleHint()){
@ -162,7 +156,7 @@ public class MainActivity extends AppCompatActivity
newNotif++;
updateNotifCounter();
}
}else if(eventStreaming == StreamingUserAsyncTask.EventStreaming.UPDATE){
}else if(eventStreaming == StreamingService.EventStreaming.UPDATE){
Status status = b.getParcelable("data");
if( homeFragment != null){
if(homeFragment.getUserVisibleHint()){
@ -176,7 +170,7 @@ public class MainActivity extends AppCompatActivity
newHome++;
updateHomeCounter();
}
}else if(eventStreaming == StreamingUserAsyncTask.EventStreaming.DELETE){
}else if(eventStreaming == StreamingService.EventStreaming.DELETE){
String id = b.getString("id");
if(notificationsFragment != null) {
if (notificationsFragment.getUserVisibleHint()) {
@ -210,6 +204,7 @@ public class MainActivity extends AppCompatActivity
finish();
return;
}
startService(new Intent(getApplicationContext(), StreamingService.class));
Helper.fillMapEmoji(getApplicationContext());
//Here, the user is authenticated