Theme.Light android doesn’t work

“If you’re developing for API level 11 and higher, you should instead use Theme.Holo or Theme.DeviceDefault ”

We want to create a transparent activity in our app but we also want our app to use a Holo theme when run on HoneyComb +.  However, Theme.Translucent.NoTitleBar does NOT utilize the nice new Holo theme.

So your app would use Holo.Light, but your transparent activity would use the older default theme. This will look very unprofessional.

SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")

The Holo themes’ Transparent effect can be gained by setting your application theme to


But again, this has a problem. Run this on a device operating on an Android version less than HoneyComb (i.e. gingerbread) and you get an error as the theme simply doesn’t exist.



Anything added to the theme.xml in the values folder will be used as default. Anything added to the theme.xml in the values-v11 will be use when android v11 (honeycomb) or above is in use.


<?xml version="1.0" encoding="utf-8"?>

        name="MyThemeTransparent" parent="android:style/Theme.Translucent.NoTitleBar">


<?xml version="1.0" encoding="utf-8"?>

        name="MyThemeTransparent" parent="@android:style/Theme.Holo.Light.Panel">

can‘t find calss on path data/app/xxx.apk

To fix this, right-click your project, properties, build path and go to export tab. There make sure “Android private libraries” are checked. A clean and rebuild should put you on track …
Right-click the project in Eclipse’s Package Explorer and choose Properties.
Choose Java Build Path
Choose Order and Export
Check the boxes next to Android Private Libraries and Android Dependencies
After making these changes, do a clean and then rebuild.

With this change, I was able to build an APK that installed and ran on an Android device.

Eclipse “Invalid Project Description” when creating new project from existing source

Go into your workspace, and move your project source code folder to another area outside of your workspace (like the desktop). Make sure the project is deleted in eclipse, then create a new project from source from that directory.

Another thing you could do is try creating a project of a different name (from the first project’s source), so that the workspace will contain the new project as a functional project. Then, go into your workspace directory and absolutely delete the folder that contained the original project, or move it. Try loading the project from source again, this time using the second project, by naming it with the correct name. Or, you could try refactoring the second project back to the first’s name.

file uploading is corrupted [error]

1. Data URIs represent the data of the image. put all the data URIs the user drags into the box into an array, and post it to a PHP file. This PHP file will process the URIs and upload them to the server.

$randomName = substr_replace(sha1(microtime(true)), ”, 12).’.’.$mime;
if(file_put_contents($uploaddir.$randomName, $decodedData)) {
echo $randomName.”:uploaded successfully”;
else {
// Show an error message should something go wrong.
echo “Something went wrong. Check that the file isn’t corrupted”;

reason: the folder which holds the uploaded file, has no permission to be written by any user.

resolution: chmod a+w uploadfolder/

2. “I know how to submit data into a mySQL table through a form. Now I want to upload the image file to the remote directory (say, ‘images/’) but at the same time save the file-name in the table. ”

Often you want a user to be able to upload a photo, but you don’t want to bog down your database space by saving all the images directly into the database. You instead save the image to your server, but keep a record in the database of what file was saved so you can easily reference the image when needed.

First let’s create a database:

CREATE TABLE employees (name VARCHAR(30), email VARCHAR(30), phone VARCHAR(30), photo VARCHAR(30)) 

Creating a Form:

This is simply an HTML form that you would use to collect information to be added to the database.

<form enctype="multipart/form-data" action="add.php" method="POST"> 
 Name: <input type="text" name="name"><br> 
 E-mail: <input type="text" name = "email"><br> 
 Phone: <input type="text" name = "phone"><br> 
 Photo: <input type="file" name="photo"><br> 
 <input type="submit" value="Add"> 

Processing the Data: add.php

 //This is the directory where images will be saved 
 $target = "images/"; 
 $target = $target . basename( $_FILES['photo']['name']); 

 //This gets all the other information from the form 

 // Connects to your Database 
 mysql_connect("", "username", "password") or die(mysql_error()) ; 
 mysql_select_db("Database_Name") or die(mysql_error()) ; 

 //Writes the information to the database 
 mysql_query("INSERT INTO `employees` VALUES ('$name', '$email', '$phone', '$pic')") ; 

 //Writes the photo to the server 
 if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
 //Tells you if its all ok 
 echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; 
 else {  
 //Gives and error if its not 
 echo "Sorry, there was a problem uploading your file."; 
  • only allowing photo uploads, you might consider limiting the allowed file types to jpg, gif and png.
  •  check if the file already exists: not overwrite
  • simply rename each file with a unique ID

Uniqid (prefix, more_entropy)

  • prefix: what will be appended to the beginning of each ID.
  • more_entropy. If this is false or not specified it will return 13 characters, if it is true then 23 characters will be returned.

//creates a unique id with the ‘about’ prefix

$a = uniqid(about); echo $a;   echo “<br>”;

//creates a longer unique id with the ‘about’ prefix

$b = uniqid (about, true); Echo $b; echo “<br>”;

//creates a unique ID with a random number as a prefix – more secure than a static prefix

$c = uniqid (rand (),true); echo $c; echo “<br>”;

//this md5 encrypts the username from above, so its ready to be stored in your database

$md5c = md5($c); echo $md5c; ?>

crypt () In Action

$password = crypt('mypassword'); 
 print $password . “ is the encrypted version of mypassword”;
$password = crypt('mypassword' , 'd4'); print $password . " is the CRYPT_STD_DES version of mypassword<br>"; 
$password = crypt('mypassword' , 'k783d.y1g'); print $password . " is the CRYPT_EXT_DES version of mypassword<br>"; 
$password = crypt('mypassword' , '$1$d4juhy6d$'); print $password . " is the CRYPT_MD5 version of mypassword<br>"; 
$password = crypt('mypassword' , '$2a$07$kiuhgfslerd...........$'); print $password . " is the CRYPT_BLOWFISH version of mypassword<br>"; ?> 
d4/qPbCcJ5tD. is the CRYPT_STD_DES version of mypassword
k7xEagYCDPPSc is the CRYPT_EXT_DES version of mypassword
$1$d4juhy6d$a.jIPYnvne1FWF2V6mGQR0 is the CRYPT_MD5 version of mypassword
$2a$07$kiuhgfslerd...........6k0kSI76CqJ/RWGnSp9MWRDF91gJZfW is the CRYPT_BLOWFISH version of mypassword
As long as you always use the same salt the encrypted password should always be the same, making it a good solution for password storage.

Testing uploaded Data

 // Connects to your Database 
 mysql_connect("", "username", "password") or die(mysql_error()) ; 
 mysql_select_db("Database_Name") or die(mysql_error()) ; 

 //Retrieves data from MySQL 
 $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); 

//Puts it into an array

while($info = mysql_fetch_array( $data )) {

//Outputs the image and other data

Echo "<img src=".$info['photo'] ."> <br>";

Echo "<b>Name:</b> ".$info['name'] . "<br> ";

Echo "<b>Email:</b> ".$info['email'] . " <br>";

Echo "<b>Phone:</b> ".$info['phone'] . " <hr>";

} ?>

To show the image, we just use normal HTML for the image, and only change the last part (the actual image name) with the image name stored in our database.


[error] phpmailer Could not instantiate mail function.

In Ubuntu (at least 12.04) it seems sendmail is not installed by default. You will have to install it using the command sudo apt-get install sendmail-bin

You may also need to configure the proper permissions for it as mentioned above.

$msg = nl2br(strip_tags($_POST['message']));
// Using the PHPMailer class
$mail = new PHPMailer();
// Adding the receiving email address
$mail->Subject = 'AisforArt Feedback';
$mail->AddReplyTo('noreply@'.$_SERVER['HTTP_HOST'], 'Quick Feedback');
$mail->SetFrom('noreply@'.$_SERVER['HTTP_HOST'], 'Quick Feedback');
echo 'Thank you!';

Few points to check:
1> is mail function disabled in your server?
This can be checked by using:

PHP Code:
mail("", "Test Subject", "Test Message");

2>is mail From param valid?

PHP Code:
$mail->From = $email;

3> did you try with SMTP?

PHP Code:

What is PHP_SELF variable?

PHP_SELF is a variable that returns the current script being executed. This variable returns the name and path of the current file (from the root folder). You can use this variable in the action field of the FORM.

echo $_SERVER['PHP_SELF'];

a) Suppose your php file is located at the address:

In this case, PHP_SELF will contain:

b) Suppose your php file is located at the address:

For this URL, PHP_SELF will be :

ssh secure file transfer client – no response

改变在linux下的目录:cd /usr/
改变在windows下的目录: lcd d:/  [如果不改变的话就是默认putty的安装目录,默认下载到这儿,上传的文件也是要在这个文件夹里面]

上传文件到linux: psftp> put filename
从linux下载文件: psftp> get filename




首先,在windows 下运行命令提示符界面,psftp.exe ,登录后改变在linux下的目录:


生成Android Dependencies [error]

第三方jar包放入libs文件夹后可以右键Android Tools->Fix Project Properties就可以自动导入Android Dependencies里

工程下的.classpath的文件, <classpathentry exported=”true” kind=”con” path=””/>就可以解决,Refresh一下,顺便clean一下,OK,完成!

Universal-Image-Loader: OutOfMemory Error

If you often got OutOfMemoryError in your app using Universal Image Loader then try next (all of them or several):

  • Reduce thread pool size in configuration (.threadPoolSize(...)). 1 – 5 is recommended.
  • Use .bitmapConfig(Bitmap.Config.RGB_565) in display options. Bitmaps in RGB_565 consume 2 times less memory than in ARGB_8888.
  • Use .memoryCache(new WeakMemoryCache()) in configuration or disable caching in memory at all in display options (don’t call.cacheInMemory()).
  • Use .imageScaleType(ImageScaleType.IN_SAMPLE_INT) in display options. Or try.imageScaleType(ImageScaleType.EXACTLY).
  • Avoid using RoundedBitmapDisplayer. It creates new Bitmap object with ARGB_8888 config for displaying during work.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context)
.threadPoolSize(3) // equal to default value
.threadPriority(Thread.NORM_PRIORITY - 1) // equal to default value
.memoryCache(new WeakMemoryCache())
.discCacheExtraOptions(720, 480, CompressFormat.JPEG, 75)
.discCache(new UnlimitedDiscCache(cacheDir)) // You can pass your own disc cache implementation
.discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // equal to default value
.imageDownloader(new URLConnectionImageDownloader(120 * 1000, 120 * 1000)) // connectTimeout (5 s), readTimeout (20 s)
.defaultDisplayImageOptions(DisplayImageOptions.createSimple()) // equal to default value


[error] android.os.NetworkOnMainThreadException

Caused by: android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(

In Honeycomb they’ve gone and put in a trap to catch people trying to do potentially time-consuming network operations on the main thread.


The exception that is thrown when an application attempts to perform a networking operation on its main thread.

This is only thrown for applications targeting the Honeycomb SDK or higher. Applications targeting earlier SDK versions are allowed to do networking on their main event loop threads, but it’s heavily discouraged. See the document Designing for Responsiveness. Also see StrictMode.

New Gingerbread API: StrictMode


Because things like looking up a host name can take a long and somewhat indeterminate amount of time, they should not be called from the event functions on the main thread which are required to return quickly (as in within a few milliseconds). If one of these functions takes too long to return, Android loses the ability to send messages to the program, and may pop up the dreaded Application Not Responding dialog.


You should move your networking operations (at least any that require waiting for a result or for a blockage to clear so you can send more) to a thread. If the network operations are coming from an piece of API code, you probably shouldn’t be calling that on the main thread.

Possible tools are AsyncTask and the normal Java ThreadAndroid Threads, Handlers and AsyncTask – Tutorial






当show dialog时,后面的工作要交给线程去处理,并在线程里面cancle dialog,而且最好把ProgressDialog定义该界面本身的一个私有变量,在每次要调用时进行初始化。

每次触发时,new 一个新的ProgressDialog,就可以了。


  • style=”?android:attr/progressBarStyleHorizontal”//设置ProgressBar的类型为水平条状 
  • style=”?android:attr/ progressBarStyleSmall “//设置ProgressBar的类型为小圆圈
  • style=”?android:attr/progressBarStyle”//设置ProgressBar的类型为中等圆圈
  • style=”?android:attr/progressBarStyleLargeInverse”//设置ProgressBar的类型为反转的大圆圈
  • 在转圈的样式参数后面加上Inverse,即progressBarStyleSmallInverse,progressBarStyleInverse,progressBarStyleLargeInverse,就可以得到反转的转圈进度条了。当后面的背景色是白色或者是亮色,使得progressBar效果很不明显




error: 在xml中定义android:onclick=”xxx” [error: String resource ID #0x6]




public void onClick_Event(View view) {
TextView textview = (TextView)findViewById(;

只需在正确的Activity 中增加一个成员函数onClick_Event(),并在xml文件中加入对其的使用描述即可。代码结构简单,清晰,代码量也大大减少,并且通过xml文件的可配置性,增长了工程的可维护性,模块化进一步增强! 推崇。

  • android.content.res.Resources$NotFoundException: String resource ID #0x6

想让某个TextView对象显示一个数字,直接调用了setText()方法:tv1.setText(100);  运行时ForceClose


setText(int resid),这里的int型参数表示的是资源ID,而不是显示到TextView的数字。所以要在TextView中显示一个int类型整数,不能直接将此整数直接作为参数。修改为:tv1.setText(String.valueOf(100));





Just another site

Jing's Blog

Just another site

Start from here......







Just another site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision


Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness



Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web