Author Archives: Jack

How to use Unix Timestamp with Java

You can use a unix timestamp in java wit the following code:

import java.util.Date;
String TimeStamp = "1324716371";
Date time=new Date((long)TimeStamp*1000);

Now, timestamp doesn't have to be a string, however in many of your projects you may have the value in that format. In this case, we convert it to a long (integer is too small), and then multiply it by 1000 since Java uses milliseconds.

How to get the version name from the AndroidManifest.xml file

Use the following code snip in your application:

try
{
    String VersionName = this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName;
}
catch (NameNotFoundException e)
{
    Log.v(tag, e.getMessage());
}

Android - How to scroll a workspace/activity/layout

You need to add the ScrollView FrameLayout.  A great example on how to do this can be found here:

http://android-pro.blogspot.com/2010/02/android-scrollview.html

How to remove the title or "Application Name" bar

To remove the bar that appears at the top of your activity, modify your AndroidManifest.xml document.  Foreach activity, add the line:

android:theme="@android:style/ThemeNoTitleBar.Fullscreen"

Making the result look like:

<activity android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.NoTitleBar.Fullscreen">

Android - How to save application settings/preferences

Here is the answer! 🙂

http://stackoverflow.com/questions/2154438/how-to-implement-remember-me-function-in-login-of-android-activity

How to import a project

Have a zip file and want to import it into eclipse?  Easy.

  • File->Import->General->Existing Projects Into Workspace
  • Check select archive file, click browse and select the archive.
  • Under Projects, select the project it found.
  • Click Next

Done!