use of com.baker.abaker.workers.CheckInternetTask in project baker-android by bakerframework.
the class MagazineThumb method checkInternetAccess.
private void checkInternetAccess() {
CheckInternetTask checkInternetTask = new CheckInternetTask(MagazineThumb.this.getContext(), MagazineThumb.this, CHECK_INTERNET_TASK);
checkInternetTask.execute();
}
use of com.baker.abaker.workers.CheckInternetTask in project baker-android by bakerframework.
the class GindActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
if (this.getActionBar() != null) {
this.getActionBar().hide();
}
sdfInput = new SimpleDateFormat(getString(R.string.inputDateFormat), Locale.US);
sdfOutput = new SimpleDateFormat(getString(R.string.outputDateFormat), Locale.US);
Intent intent = this.getIntent();
if (intent.hasExtra("START_DOWNLOAD")) {
this.startDownload = intent.getStringExtra("START_DOWNLOAD");
}
try {
loadingScreen();
STANDALONE_MODE = getResources().getBoolean(R.bool.run_as_standalone);
//Getting the user main account
AccountManager manager = AccountManager.get(this);
Account[] accounts = manager.getAccountsByType("com.google");
// any account the user have on the phone.
if (accounts.length == 0) {
accounts = manager.getAccounts();
}
if (accounts.length != 0) {
// We will use the first account on the list.
userAccount = accounts[0].type + "_" + accounts[0].name;
} else {
// Wow, if we still do not have any working account
// then we will have to use the ANDROID_ID,
// Read: http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID
Log.e(this.getClass().toString(), "USER ACCOUNT COULD NOT BE RETRIEVED, WILL USE ANDROID_ID.");
userAccount = Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
}
Log.d(this.getClass().getName(), "APP_ID: " + this.getString(R.string.app_id) + ", USER_ID: " + userAccount);
if (checkPlayServices()) {
Log.d(this.getClass().getName(), "Google Play Services enabled.");
gcm = GoogleCloudMessaging.getInstance(this);
registrationId = getRegistrationId(this.getApplicationContext());
Log.d(this.getClass().getName(), "Obtained registration ID: " + registrationId);
registerInBackground();
} else {
Log.e(this.getClass().toString(), "No valid Google Play Services APK found.");
}
if (STANDALONE_MODE) {
activateStandalone();
} else {
CheckInternetTask checkInternetTask = new CheckInternetTask(this, this, CHECK_INTERNET_TASK);
checkInternetTask.execute();
}
SharedPreferences sharedPreferences = this.getPreferences();
if (sharedPreferences.getBoolean(Configuration.FIRST_TIME_RUN, true) && getResources().getBoolean(R.bool.ut_enable_tutorial)) {
//the app is being launched for first time, do something
Log.d(this.getClass().getName(), "First time app running, launching tutorial.");
showAppUsage();
sharedPreferences.edit().putBoolean(Configuration.FIRST_TIME_RUN, false).apply();
}
// Here we register the APP OPEN event on Google Analytics
if (getResources().getBoolean(R.bool.ga_enable) && getResources().getBoolean(R.bool.ga_register_app_open_event)) {
((ABakerApp) this.getApplication()).sendEvent(getString(R.string.application_category), getString(R.string.application_open), getString(R.string.application_open_label));
}
} catch (Exception e) {
e.printStackTrace();
Log.e(this.getClass().getName(), "Cannot load configuration.");
}
}
Aggregations