söndag 19 augusti 2012

How to fix undeletable Netbeans projects

I had web application project in Netbeans that I wanted to delete, and replace with a new project with the same name. Everyting worked fine until I tried to deploy it to glassfish. Then it failed. It looked like it was missing some session bean classes used for a REST interface  from the earlier deleted project with the same name.  I used diff and other tools to find the now missing classes, but they where nowhere to bi found. So, what to do. I could of course have renamed it but I didn't want to do that.

The solution was to create a new project with the same name but in a different folder, and then export it to zip, and then import it back in the original directory.

lördag 18 augusti 2012

Eclipse Juno on CentOS 6.3

When I tried to upgrade to the new Eclipse Juno release. The program died due to some incompatibility in xulrunner. The problem was solved by using webkit for rendering instead.  After installing the webkitgtk package eclipse started just fine.

tisdag 29 maj 2012

How to create a splash screen in Android

Splash screens are not really an Android thing.  Most Android users would like their app to start as fast as possible and will be annoyed by a splash screen. So avoid it in your own apps, and try to talk customers out of using it.  However there are situations where it might be needed, one of them would be if your app need to load some large amount of data before it can be run. In that case the splash gives can tell the user that the application is loading.

The easiest way to create a splash  would be to create it as a separate activity that dies after a while.
Something like this would do.  Just put your splash image e.g. as a png image in your drawable folder
and start the Splash activity by sending an intent  from your main app code.


import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Window;
import android.widget.ImageView;

public class Splash extends Activity {
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  ImageView v = new ImageView(this);
  v.setImageResource(R.drawable.splash);
  setContentView(v);
  AsyncTask t = new AsyncTask(){

   @Override
   protected Void doInBackground(Void... params) {
    try {
     //Show the splash one second
     Thread.sleep(1000);
    } catch (InterruptedException e) {
     e.printStackTrace();
    }
    return null;
   }

   @Override
   protected void onPostExecute(Void result) {
    finish();
   }
   
  };
  t.execute();
  
 }
}


fredag 11 maj 2012

How to prevent soft keyboard from showing up in Android

I had an app that consisted of a two AutoCompleteTextViews and a few other controls. As the text fields might have good default values, when the user opens the app, I wanted to hide the soft keyboard. To do that I finally found out that I should add

android:windowSoftInputMode="stateHidden"

to the activity tag in the AndroidManifest.xml. This worked fine even though the AutoCompleteTextView actually resided inside a Fragment hosted by the activity.