How to refresh the current Android Fragment

To refresh the current Android Fragment you can use the snippet below. The code must be placed inside the Fragment that needs to be updated. The snippet will call the onCreateView Method of the Fragment.

Samples

Sample Java

If you have any questions or suggestions feel free to rate this snippet, post a comment or Contact Us via Email.

Related links:

Please rate this snippet

How to set the ios bookmark icon in HTML

To set the ios bookmark icon in HTML you can use the following snippet.

Sample HTML

<link rel="apple-touch-icon" href="iOs_Icon.png"/>

If your icon is already glossy, you can prevent the device from adding its own gloss by using.

Sample HTML

<link rel="apple-touch-icon-precomposed" href="iOs_Icon.png"/>

Please rate this snippet

How to detect a screen orientation change in Javascript

To detect a screen orientation change in Javascript you can use the following snippet.

Sample Javascript

window.addEventListener("orientationchange", function() {
	//0 = potrait
	//90 or -90 = landscape left or landscape right
}, false);

some devices do not fire the orientationchange event, try the resize event instead.

Sample Javascript

window.addEventListener("resize", function() {
	// check screen size (inner and outer!)	
}, false);

Please rate this snippet

How to check if a userAgent is a mobile device in jQuery

To check if the userAgent is a mobile device in jQuery you can use the following snippet.
It will match the following:

  • • Android
  • • webOS
  • • iPhone
  • • iPad
  • • iPod
  • • BlackBerry

Sample jQuery

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/.test(navigator.userAgent) ) {
	// mobile device
} 
else 
{
	// other device
}

Please rate this snippet