Hi all,

JavocSoft Android Toolbox Library

After a few weeks i have acumulated changes that fix a few things and improve a bit the library JavocSoft Android Toolbox. From now i will wait until i have enough changes before upgrading it. In this update there are changes related to location service, SQLite module and fixes to the ToolBox itsef. Below the list of changes:

  • ToolBox:
    • Lately I have been using notification button actions in some applications and  I realized that the method I had for it it wasn’t very good because I still had to code a bit. Because of this, I created a new method “notification_createActionButton()”. Now you only need to pass some arguments and do not need to code nothing to get the action. Remenber that notification buttons are available since Android 4.1+ (compatibility classes are used anyway). Now is really very easy to create notification action buttons 🙂
    • If you get in an application this message in the logcat:
      Choreographer(abc): Skipped xx frames! The application may be doing too much work on its main thread.
      You have a problem that need to be solved because it can be a perfomance problem in your app, you may be doing to much work in the main application UI thread.
      To help solving it, there is a new method “” that enables Android StrictMode warning logs and appropiate actions so you can locate the source code responsible of the bad perfomance.
    • There is also a new method “threadIsMainApplicationUIThread()” that returns TRUE if the current thread is the main application UI thread.
  • SQLite:
    • DBHelper. Added update methods “updateWhere()”.
    • SQLite. Fixed a bug in DBSQLite in the method “onUpgrade()”. The bug made updates to do not be done.
  • Location Service:
    • Now logs only are printed if the debug mode is ON.
    • Now location updates are discarded if is the same location or if the distance between location (appbox amazonapps using Haversine formula) is minor than the minimal distance threshold.

 

I hope this changes help you a bit more using JavocSoft Android Toolbox 🙂

Do not forget to check the blog to get more updates!

More info and HowTo at https://github.com/javocsoft/javocsoft-toolbox/wiki.

github_icon

As always, library is available on GitHub

javocsoft-toolbox.

Bye.

JavocSoft 2015.

Hi all again,

Today i have had time to isolate a class to have a localization service ready-to-use in the library JavocSoft Android Toolbox.

JavocSoft Android Toolbox LibraryThis will allow, very easily, to have an application that watches for any location change (or GPS enabled/disabled) event in background even if the application is not running because is an Android service 🙂

To use it, first declare in your AndroidManifest.xml:

<service android:name="es.javocsoft.android.lib.toolbox.location.service.LocationService" android:label="Location Service" android:enabled="true"/>

And launch it:

Intent mLocServiceIntent = new Intent(getBaseContext(), LocationService.class);
Bundle extras = new Bundle();
extras.putInt(LocationService.LOCATION_SERVICE_PARAM_MIN_DISTANCE, 2);
extras.putInt(LocationService.LOCATION_SERVICE_PARAM_MIN_TIME, 4000);
mLocServiceIntent.putExtras(extras);
startService(mLocServiceIntent);

And to stop it, when required:

Intent mLocServiceIntent = new Intent(getBaseContext(), LocationService.class);
stopService(mLocServiceIntent);

 

The localization service can also be customized when launched by setting in the service launching intent these parameters:

  • LocationService.LOCATION_SERVICE_PARAM_MIN_DISTANCE
  • LocationService.LOCATION_SERVICE_PARAM_MIN_TIME

Once is running, the service will broadcast the following events:

  • LOCATION_SERVICE_STARTED. Intent filter name:
    es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_SERVICE_STARTED
  • LOCATION_SERVICE_SHUTDOWN. Intent filter name:
    es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_SERVICE_SHUTDOWN
  • LOCATION_CHANGED. Intent filter name:
    es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_CHANGED
  • LOCATION_GPS_DISABLED. Intent filter name:
    es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_GPS_DISABLED
  • LOCATION_GPS_ENABLED. Intent filter name:
    es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_GPS_ENABLED

So now, to attend the localization events you only have to create a BroadcastReceiver:

public class LocationChangedReceiver extends WakefulBroadcastReceiver {
 
 protected static String TAG = "LocationChangedReceiver";
 
 
 public LocationChangedReceiver() {
 
 }
 @Override
 public void onReceive(Context context, Intent intent) {
 
   Bundle bundle = intent.getExtras(); 
   if(intent.getAction().equals(LocationService.ACTION_LOCATION_CHANGED)) { 
     //The Location Service leaves the detected location in the extras using
     //the key LocationService.LOCATION_KEY.
     Location location = bundle.getParcelable(LocationService.LOCATION_KEY);
     //Do something
   }else if(intent.getAction().equals(LocationService.ACTION_LOCATION_GPS_ENABLED)){
     //Do something
   }else if(intent.getAction().equals(LocationService.ACTION_LOCATION_GPS_DISABLED)){
     //Do something
   }else if(intent.getAction().equals(LocationService.ACTION_LOCATION_SERVICE_STARTED))
     //Do something 
   }else if(intent.getAction().equals(LocationService.ACTION_LOCATION_SERVICE_SHUTDOWN)){
     //Do something
   }
 }
}

And declare this receiver in your application AndroidManifest.xml:

<receiver android:name="your_application_package.LocationReceiver" android:enabled="true" android:exported="false"/>
 <intent-filter>
 <action android:name="es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_SERVICE_STARTED"/>
 <action android:name="es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_SERVICE_SHUTDOWN"/>
 <action android:name="es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_CHANGED"/>
 <action android:name="es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_GPS_ENABLED"/>
 <action android:name="es.javocsoft.android.lib.toolbox.location.service.intent.action.LOCATION_GPS_ENABLED"/>
 </intent-filter>
<receiver/>

 

I hope this addition make your life easier 🙂

Do not forget to check the blog to get more updates!

More info and HowTo at https://github.com/javocsoft/javocsoft-toolbox/wiki.

github_icon

As always, library is available on GitHub

javocsoft-toolbox.

Bye.

JavocSoft 2015.

Hi all,

With new versions of Android, the library needs to be adapted to deal with new possibilities JavocSoft Android Toolbox Libraryand requirements. In this case, the new library JavocSoft Android Toolbox version has resources to handle new Android 6+ Permission system. This will allow us to embrace and adapt our applications to Android 6 new permissions usage approach.

Android 6 and Permissions

Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. If the device is running Android 5.1 (API level 22) or lower, or the app’s targetSdkVersion is 22 or lower, the system asks the user to grant the permissions at install time.

System permissions are divided into two categories, normal and dangerous (more info):

  • Normal permissions do not directly risk the user’s privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically. See the list here.
  • Dangerous permissions can give the app access to the user’s confidential data. If your app lists a normal permission in its manifest, the system grants the permission automatically. If you list a dangerous permission, the user has to explicitly give approval to your app. If an app requests a dangerous permission listed in its manifest, and the app already has another dangerous permission in the same permission group, the system immediately grants the permission without any interaction with the user.

See Google Developer Permissions to know more about it.

Adapt your application

To adapt an application to the new permissions usage approach of Android 6+, the application has to be able to deal with these use cases:

  • Start the App. Ask for permission (showing before a message telling why do you need before ask for them)
    • Accept. Ask for permissions:
      • Accept -> App runs normally with the service that requires the permissions.
      • Not accept -> App runs normally without the service that requires the permissions.
    • Cancel. App runs normally without the service that requires the permissions.
  • With previously granted permissions, start the App:
    • Start the App -> App runs normally with the service that requires the permissions.
  • In a running App with granted permissions:
    • Deny the permissions -> When returning to the App, it Asks for permissions (showing before a message telling why do you need before ask for them):
      • Accept. Ask for permissions:
        • Accept -> App runs normally with the service that requires the permissions.
        • Not accept -> App runs normally without the service that requires the permissions.
      • Cancel. App runs normally without the service that requires the permissions.
  • User denies the permission and marks “Never ask again”
    • Start the App:
      • Show a message to the user about the required permissions (showing before a message telling why do you need before ask for them)
        • Accept. Ask for permissions:
          • Accept -> App runs normally with the service that requires the permissions.
          • Not accept -> App runs normally without the service that requires the permissions.
        • Cancel. App runs normally without the service that requires the permissions.

For devices with Android minor than 6 version, API Level 23, you should be able to open the application normally and use it without prompting for any permission because they are already granted when the application is installed.

 

The library JavocSoft Android Toolbox gives you the method to achieve these point in a relative easy way.

Usage

ToolBox provides methods to check for permissions allowing us to present to the user an informative dialog and also ask to allow them if they are not already granted. ToolBox uses the Android Support Library for backward Android compatibility.

The list of functions to handle permissions are:

  • permission_askFor
  • permission_checkAskPermissionsresult
  • permission_isGranted
  • permission_areGranted

ToolBox also provides a set of permissions packages according with Google permissions group. This makes easy for you to ask for permissions for a service that requires a set of permissions.

  • PERMISSION_CALENDAR
  • PERMISSION_CAMERA
  • PERMISSION_LOCATION
  • PERMISSION_MICROPHONE
  • PERMISSION_PHONE
  • PERMISSION_SENSORS
  • PERMISSION_SMS
  • PERMISSION_STORAGE

Here is an example of usage. In this case we are going to use the localization service.

This service requires two permissions that are not automatically granted (not in Google NORMAL permissions group):

  • ACCESS_COARSE_LOCATION
  • ACCESS_FINE_LOCATION

ToolBox has these two permissions in the PERMISSION_LOCATION set. We will use this set to ask for permission to the user:

<!-- Before use it, we check if the permissions are already granted. -->
if(!ToolBox.permission_areGranted(TheActivity.this, ToolBox.PERMISSION_LOCATION.keySet())) {
    //Permissions not yet granted, we need to be ask.
    ToolBox.permission_askFor(TheActivity.this, ToolBox.PERMISSION_LOCATION,     
            ToolBox.PERMISSIONS_REQUEST_CODE_ASK_LOCATION, 
        getString(R.string.permissions_required_title), 
        getString(R.string.permissions_button_ok),
        getString(R.string.permissions_button_deny),
        getString(R.string.permissions_location_required_text));
}else{
     //Permissions are already granted, continue using the localization service...
 
}

To handle the permissions ask response, we must do the following:

<!-- This method handles the response -->
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
    permissionsLocationGranted = checkAskPermissionsresult(requestCode, permissions, grantResults);
    Log.i(Constants.TAG, "Location permissions granted? " + permissionsLocationGranted);
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
 
    if(permissionsLocationGranted) {
        //Continue with the usage of the service that needs the permissions...
 
    }else{
        //Do something if required...
    }        
}
 
private boolean checkAskPermissionsresult(int requestCode, String[] permissions, int[] grantResults) {
    boolean res = false;   
    if(requestCode == ToolBox.PERMISSIONS_REQUEST_CODE_ASK_LOCATION) {
            //We could check the permissions in our system
        //res = ToolBox.permission_areGranted(SplashActivity.this, Arrays.asList(permissions));         
            //We check the returned result. Only returns TRUE if all permissions are granted.
        res = ToolBox.permission_checkAskPermissionsresult(permissions, grantResults);
    }
    return res;
}

Have in mind that every time you use a service o function that requires permissions, you should check the current permissions by using:

ToolBox.permission_areGranted(TheActivity.this, ToolBox.PERMISSION_LOCATION.keySet());

To know more about it goto https://github.com/javocsoft/javocsoft-toolbox/wiki#android-6-permissions-handle.

 

Recommended videos about permissions in Android M that you should check:

 

I hope these addition could be useful for your applications.

Do not forget to check the blog to get more updates!

More info and HowTo at https://github.com/javocsoft/javocsoft-toolbox/wiki.

github_icon

As always, library is available on GitHub

javocsoft-toolbox.

Bye.

JavocSoft 2015.

Hola,

Nos alegra comunicaros que ahora la mejor web para pasar el rato, WCTime Web (http://www.wctime.javocsoft.es), con imágenes, memes wctime_icony Gifs animados, ya permite crear una cuenta para por ejemplo, marcar imágenes como favoritos y así poder guardar las que más te gusten para compartirlas más tarde o coleccionarlas.

 

Iremos añadiendo poco a poco más cosas y más adelante, incluso subir tus propios memes e imágenes 🙂

Recordad que también tenéis el contenido vía aplicación en el store de Android, WCTime Play Store.

 

Espero la sigáis disfrutando y ya sabéis, si os gusta, dadle un Like 🙂 y/o descargad la app.

Un saludo,

Hola,

LLevábamos ya un tiempo pensando en disponer del contenido de la aplicación WCTime en la webwctime_icon para que cualquiera pudiera pasar un rato entretenido directamente, sin tener que bajar la aplicación.

Hoy esta por fín WCTime esta on-line en la web! Es una primera versión que irá evolucionando aún.

Teneis WCTime On-Line en http://www.wctime.javocsoft.es

 

Espero que os haga pasar buenos ratos y ya sabéis, si os gusta, dadle un Like y/o descargad la app.

Un saludo,

 

Mejora de servicios y actualización de WCTime.mantenimiento-equipos-servidores-redes

En esta ocasión hemos actualizado algunos servicios que requerían mantenimiento para mejorar sus funciones y/ó corregir fallos. Hemos aprovechado también para actualizar una aplicación, WCTime, que llevaba tiempo sin mostrar contenido, nos disculpamos a los usuarios por ello.

 

Actualizada la aplicación WCTime

wctime_iconLlevaba un tiempo sin mostrar contenido. Se ha corregido el problema en el servidor y la aplicación y subido la nueva versión al store de Google Play. Ya vuelve a haber contenido. Sentimos haber tardado tanto en aplicar el fix. A los que no la conocen aún os animo a descargarla y probarla, es una aplicación para pasar el rato. La podéis descargar aquí.

 

Actualizado servicio TextSanitizer

text_sanitizer_logoSe ha mejorado para que no sea tan restrictivo y permita emojis y algunos caracteres extra. También se ha mejorado el propio filtro en sí. Como siempre, lo tenéis accesible aquí. Os recordamos que podéis acceder también vía API de manera totalmente gratuita, más información.

 

Actualizado servicio ShortnumbersInfo (información de SMS premium de números cortos)

shortnumbers_info_logo

Parece que no se estaba mostrando la información de algunos números cortos de 5 cifras. Ahora se muestra la información de aquellos que empiezan por 23xxx y 33xxx, usados para servicios de juegos y también los que empezaban por 380xx usados para fines solidarios. tenéis el servicio
disponible aquí. Os recordamos que también podéis usar el servicio vía API de manera totalmente gratuita, más información. Además, tenemos una aplicación image_iconpara Android, AppVigilant, que usa la misma tecnología y que instalándola, nos evitaremos posibles sorpresas en la factura al avisarnos cuando enviamos o recibimos un mensaje de este tipo. Alertándonos también de posibles suscripciones, pudiéndonos incluso darnos de baja desde la propia aplicación, disponible en Google Play.

 

Esperamos que os agraden los cambios y os damos las gracias por la paciencia.

 

Un saludo,