Skip to content

ProgressDialog with custom view

In one of my application I had to download data from server which took almost 10-15 seconds and I didn’t want my users to stare at a progress dialog with just showing loading message.

I wanted to customize the default ProgressDialog to display interesting facts so that the user feels that he is not waiting too long for the data.

My first step was to create my own layout and set the layout using the method setContentView method. But seems this method though available for the developers cannot be used since it throws error

android.util.AndroidRuntimeException: requestFeature() must be called before adding content

So I tried to write my own dialog by sub classing Dialog but figured out that there is a better way by sub classing AlertDialog.

AlertDialog.Builder builder = new AlertDialog.Builder(context);
progressView = LayoutInflater.from(context).inflate(R.layout.progress_dyk, null);
builder.setView(progressView);
progress = builder.create();
progress.requestWindowFeature(Window.FEATURE_NO_TITLE);

progress.show();

Advertisements

Eclipse: JVM Terminated. Exit code=-1

I have been using my eclipse instance for months and on the day of a crucial release it stopped working (May be just to prove Murphy’s law). I had several instance of eclipse (I usually have different instance for J2EE, Android, Blackberry etc) and all the instance showed me exactly the same error.

JVM terminated. Exit code=-1
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=512M
-Djava.class.path=D:\eclipse\Android\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
-os win32
-ws win32
-arch x86
-showsplash
-launcher D:\eclipse\Android\eclipse\eclipse.exe
-name Eclipse
–launcher.library D:\eclipse\Android\eclipse\plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519\eclipse_1206.dll
-startup D:\eclipse\Android\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
-product org.eclipse.epp.package.java.product org.eclipse.platform
-vm C:\Java\jre6\bin\client\jvm.dll
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m
-XX:MaxPermSize=512M
-Djava.class.path=D:\eclipse\Android\eclipse\plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar

Tweaking all the memory size parameters in eclipse.ini but irrespective of whatever permutation and combination I tried it didn’t budge.

I then removed all the contents of eclipse.ini and voila! it worked perfectly but then I thought these values are there for a reason and removing everything might cause some other issue. Hence I started putting back the values one by one and figured out that removing the following 2 lines in the ini file fixed the problem.

–launcher.XXMaxPermSize
512M
–launcher.XXMaxPermSize
512M

After pin pointing the problem area I added these parameters but tried with different values and after trial and error found that value 128M worked perfectly. Now the final eclipse.ini looks like the one shown below.

-startup
plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar
–launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
-product
org.eclipse.epp.package.java.product
-showsplash
–launcher.XXMaxPermSize
128M
–launcher.XXMaxPermSize
128M
org.eclipse.platform
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m

I am still not sure what is the root cause of this issue. May be restarting the machine and reverting back the value to 512 M might do the trick.