Hi,

When using Google GCM, we have to be sure that the message is properly encoded, in case of non-latin characters, when reaching to the devices to avoid weird characters when is show.gcm-logo-e1357123459595

To achieve this, the first approach could be to do an URL-Encode the message and decode it when get from the notification but in case of iOS, if the application is not in foreground, the notification goes directly to the system and there we can not do a URL-Decode so, the correct way, when using GCM through HTTP, is to encode properly the JSON GCM request in UTF-8 before making the POST to GCM. As a brief, with Apache HTTP:

  • Add “http.protocol.content-charset” with the value “UTF-8” to the POST request.
  • Set the JSON data through an StringEntity with “UTF-8” character encoding set.

Here i put an example of GCM JSON for a HTTP POST:

{
	"collapse_key":"collapse_key_value",
	"delay_while_idle":false,
	"data":{
		"title":"Notification title",
		"message":"Hi iOS and Android",
		"url":"url_address",
		"sound":"default"	
		},
	"notification":{
		"title":"Notification title",
		"body":"Hi iOS and Android",
		"sound":"default",
		"url":"url_adress"
	},
	"registration_ids":["registration_id"]
}

and here the request, POST, with Apache HTTP client of the GCM JSON:

//Create the HttpClient and Configure
DefaultHttpClient httpclient = new DefaultHttpClient();
 
// The time it takes to open TCP connection.
httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECTION_DEFAULT_TIMEOUT);
// Timeout when server does not send data.
httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, CONNECTION_DEFAULT_DATA_RECEIVAL_TIMEOUT);
// Some tuning that is not required for bit tests.
//httpclient.getParams().setParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false);
httpclient.getParams().setParameter(CoreConnectionPNames.TCP_NODELAY, true);
 
//Set the header of the content to UTF-8
httpMethod.setHeader(CoreProtocolPNames.HTTP_CONTENT_CHARSET, "UTF-8");//Set the content through an StringEntity specifying the "UTF-8".
StringEntity se = new StringEntity(jsonData, "UTF-8");((HttpPost)httpMethod).setEntity(se); 
HttpResponse response = httpclient.execute(httpMethod);

 

 

Give it a try if you are with such character issues.

 

bye!

Hi all,

Today a new version of the library JavocSoft Android Toolbox have been released, in this case with a new module that integrates the Google Drive API. This allows to use Android ToolBox - Google DriveGoogle Drive within your applications in a really easy way. I wanted to add this to the library long time ago but until a few weeks i could not start doing it.JavocSoft Android Toolbox Library

To know how to use it and more  goto https://github.com/javocsoft/javocsoft-toolbox/wiki#google-drive.

As a brief, the list of operations that the new module for Google Drive allows are:

  • Create a file (with the posibility of creating it in the secure application folder).
  • Search for files.
  • Get a file given its name or title
  • Get the file contents.
  • Pin a file (this makes Google Drive to store a copy of its metadata locally in the Device).
  • Trash/Un-trash a file.
  • Be notified when a file changes (see TBDrive#addFileChangeListener() and TBChangeListener.java)
  • Subscribe to file changes (notifications are received even if the application is not running. See TBDrive#subscribeToFile() and TBDriveEventService.java).
  • Commit/Discard changes to a file (also be notified when Google Drive servers finish applying changes, see TBDriveEventService.java)
  • Get file contents as an String.
  • Append/Replace text to a file.
  • Get a DriveFile object from an encoded DriveId string.

As always, 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.

Google IO 2015 – GCM 3.0

Google I/O 2015

Para los que aún no hayan visto aún esta edición, la 2015, entre las novedades, referente a GCM (Google Clud Messaging), en su versión 3.0, hay una serie de novedades que merecen ser nombradas:

Para no perderte las novedades, si aún no lo viste, haz clic en Google I/O 2015 – Google Cloud Messagin 3.0. Tenéis también la web https://developers.google.com/cloud-messaging en donde poder ver todo lo relativo a GCM.

Como siempre, poco a poco iré integrando estas novedades en la librería Android javocsoft-toolbox, para que podáis disfrutar de dichos cambios de una manera sencilla.

 

Os dejo los videos, a modo recopilatorio, del evento ya pasado.

Y aquí otras exposiciones sobre temas concretos:

 

Un saludo,

Hi all,

I am still finishing the Maps integration and other things to the JavocSoft Android Toolbox Library while preparing some documentation related to GCM and a few HowTos (you can read anyway the Wiki on GitHub) but meanwhile, i have added some useful animation methods that i would JavocSoft Android Toolbox Librarylike to share :).

The new stuff is:

  • Apply animations from one activity to another by using: animation_applyAnimationToActivityLoad().
  • Apply animations to a View by using new methods animation_getFromAnimResourceId() and animation_applyAnimationTo().
  • A set of predefined animations ready to use in your projects. Complete list:
    • Blinking: blink
    • Zooming: zoom_in.xml, zoom_out.xml, zoom_out_in.xml.
    • Curtain: curtain_up.xml , curtain_down.xml, curtain_down_and_bounce.xml, curtain_left_and_right.xml, curtain_right_and_left.xml,
    • Fade: fadein.xml, fadeout.xml,
    • Directions: left_in, left_out, right_in, right_out.
    • Pushing: push_down_in, push_down_out,
    • Rotate: rotate_left_and_right.xml, rotate_right_and_left.xml, rotate_left.xml, rotate_right.xml,
    • Sliding: slide_out.xml, slide_up.xml,
    • Others: bottom_in, move.

 

As always, I hope these changes could help you a bit more than before.

Do not forget to check the blog to get the Maps integration update!

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,

Finally i have finished with the last changes in JavocSoft Android Toolbox Library and it is ready on the GitHub repository!. As a brief:

  • There is more functionallity through a lot of new methods.
  • Notifications have been updated to last Android code 5.0+. NotificationCompat is used so now, all posibilities of a notification are implemented (actions, progress bar, priority, visibility and more).
  • GCM Module is updated with the new notifications posibilities allowing to customize more the notifications.

I am still preparing Google Maps v2 integration to put a map in your application with a few lines of code, i hope i can put more time in this to finish it.

JavocSoft Android Toolbox Library

I put here the detailed changes:

  • ToolBox, Notifications:
    • Finally, migrated to NotificationCompat builder 🙂
    • Now the notification title, ticker, content info and large icon can be customized.
    • Priority and visibility implemented, for Android 5.0+ API Level 21+.
    • Implemented big style expandable notification for Android 4.1+ (API Level 16+).
    • Implemented notification actions for Android 4.1+ (API Level 16+).
    • Implemented, for Android 4.0 API Level 14+, notification progress bar (determinate & indeterminate).
    • A new class ToolBox.NotificationProgressBarRunnable has to be extended to create your own long term process.
    • Implemented RemoteViews in notifications.
    • Method notification_generate is maintained for backwards compatibility (it uses also NotificationCompat).
    • New method notification_create that allow to customize completely a notification.
  • ToolBox, Added some more utility methods:
    • device_getOSCodename
    • device_getExtraInfo
    • application_packageName
    • application_packageInfo
    • application_nameInfo
    • application_certificates
    • random_HASH
    • random_UUID
    • random_getRandom
    • random_getSecureRandom
    • gson_linkedMapAsList
    • storage_readRawResource
    • storage_readAssetResource
    • media_getDrawableFromRaw
    • media_getBitmapFromResourceId
    • media_getBitmapFromAsset
    • media_getBitmapFromRaw
    • media_getBitmap (looks, in order, for the resource in Drawable -> Assets -> Raw -> URL)
    • Some media methods to get bytes from a resource image.
  • GCM Module now supports:
    • All ToolBox notification changes. Note: Priority is set to DEFAULT and visibility to PRIVATE.
    • Customization parameters (all these parameters should be set in the data object when delivering the notification to
      the devices in GCM) are:

      • notificationId
      • notStyle
      • title
      • message
      • ticker
      • contentInfo
      • bsTitle
      • bsContent
      • bsSummary
      • bsImage
      • bsInboxStyleContent
      • bsInboxStyleLineSeparator
      • bslargeIcon
  • Added a new TextView component (widget) that allows to show HTML tags.
  • Added a JSON Gson proccesor instance. It gives you a singleton with pre-configured gson processor for a normal process, and, if desired, the possibility of use an excluding “transient” attribute JSON processor and also one excluding properties without the Exposed annotation.
  • Added official PRNG Fix class to Android with API level minor or equal to 18 (Jelly Bean) for JCA or OpenSSL PRNG.
  • BUGFIX. In some devices (depending also of Android version) the flip effect runs laggy. Added a a new flipTransition method that allows to specify to check if the current device is one of reported laggy devices (like LG G3 or Nexus 5). In case is a laggy device, depending of the parameter “enableFadeForLaggyDevices” a fade effect is used as animation instead the desired flip or no effect is applied if set to FALSE.
  • BUGFIX. crypto_getHASH() function. Hash was not correctly generated.
  • BUGFIX. Fixed a bug that made the recived text not be showed correctly if character encoding was not latin.
  • BUGFIX. GCM. Fixed an issue with the event of Notification received. No context was returned. This could make an application to crash if used.
  • BUGFIX. Toolbox. Fixed device_getOSversion. Returned info was wrong.

As i said, these are a lot of changes because i have been implementing all notifications related stuff and quite busy at work so i could not publish until today. I think now the libreruy is more useful. I now that i still have to improve some points but i am already in it so have patiente.

As always, I hope these changes could help you a bit more than before.

 

Do not forget to check the blog to get the Maps integration update!

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,

There are changes in JavocSoft Android Toolbox Library ready on the GitHub repository!. There is a bit more functionallity to it and, i am preparing Google Maps v2 integration to put a map in your application with a few lines of code, i hope i finish this soon.

JavocSoft Android Toolbox Library

The changes are:

  • Added method to show GPS settings panel, “dialog_showGPSDisabledAlert()”
  • Added DENSITY_XXXHIGH to device_getResolutionType() or unknown if not recognized.
  • Added the method location_addressInfo() to get some latitude and longitude address information.
  • Now the method “dialog_showExitConformationDialog()” allows to select if move the activity to the stack or close it.
  • Added a method “backPressedAction()” to enable the functionallity of “Press again back to exit”.
  • Added AnimationFactory class, under animation package, from Ephraim Tekle, to perform animations in a easy way. I use it and i think is quite useful.
  • Added an ImageDownloader class, under net/image package, to download image URLs in background and show them in its ImageView.
  • Added the possibility of custom Toast messages, “toast_createCustomToast()”, default ones are horrible XD.
  • Added the possibility of a custom Toast when user press the back button to exit if function backPressedAction() is used.
  • Added the method location_distance to know the distance in meters from one Map point to other using the Haversine algorithm.
  • The “dialog_showToastAlert()” method now allows to choose between system default toast and a custom one.
  • Now the method “share_newSharingIntent()” allows to filter applications using more than one application filter.
  • On Interstitial Ad now user clicks on it can be cached.

I hope these changes can help you a bit more.

Do not forget to check the blog to get the Maps integration update!

 

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.