Unfinished Posts

Posted on July 31, 2011

All the posts in this category are unfinished. Currently they are just lines of code with no explanation other than the post title. When I get time I will go back through all these posts and thoroughly comment them. ~ Blaine

QR Code to My First Sudoku Mobile App

Posted on July 31, 2011

This is the QR-Code to my first Sudoku app in the Android Market. I built this out of a tutorial in one of my Android Dev books.

Click to enlarge and scan.

Link to the app in Android Market

SharedPreferences Sample

Posted on July 29, 2011
import android.content.SharedPreferences;
SharedPreferences settings = getSharedPreferences(GAME_PREFERENCES, MODE_PRIVATE);
String lastLaunch = "First launch";
if (settings.contains("lastLaunch") == true)
	lastLaunch = settings.getString("lastLaunch", lastLaunch);
String currentTime = (String) DateFormat.format("yyyy-MM-dd hh:mm:ss", new Date());
SharedPreferences.Editor prefEditor = settings.edit();
prefEditor.putString("lastLaunch", currentTime);
prefEditor.commit();

Sample Get Current Date and Time to String

Posted on July 29, 2011
import java.util.Date;
import android.text.format.DateFormat;

 

String currentTime = (String) DateFormat.format("yyyy-MM-dd hh:mm:ss", new Date());

Sample Layout File

Posted on July 29, 2011
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    android:textColor="@color/text_top_color"
	android:textSize="@dimen/text_top_size"
    />
<TextView
	android:layout_width="fill_parent"
	android:layout_height="wrap_content"
	android:text="@string/moretext"
	/>
<ImageView
	android:layout_width="wrap_content"
	android:layout_height="wrap_content"
	android:src="@drawable/computer"
/>
</LinearLayout>

Sample arrays.xml File

Posted on July 29, 2011
<?xml version="1.0" encoding="utf-8"?>
<resources>
   <array name="difficulty">
      <item>@string/easy_label</item>
      <item>@string/medium_label</item>
      <item>@string/hard_label</item>
   </array>	

   <array name="languages">
      <item>Bulgarian (bg)</item>
      <item>Chinese Simplified (zh-CN)</item>
      <item>Chinese Traditional (zh-TW)</item>
      <item>Catalan (ca)</item>
      <item>Croatian (hr)</item>
      <item>Czech (cs)</item>
      <item>Danish (da)</item>
      <item>Dutch (nl)</item>
      <item>English (en)</item>
      <item>Filipino (tl)</item>
      <item>Finnish (fi)</item>
      <item>French (fr)</item>
      <item>German (de)</item>
      <item>Greek (el)</item>
      <item>Indonesian (id)</item>
      <item>Italian (it)</item>
      <item>Japanese (ja)</item>
      <item>Korean (ko)</item>
      <item>Latvian (lv)</item>
      <item>Lithuanian (lt)</item>
      <item>Norwegian (no)</item>
      <item>Polish (pl)</item>
      <item>Portuguese (pt-PT)</item>
      <item>Romanian (ro)</item>
      <item>Russian (ru)</item>
      <item>Spanish (es)</item>
      <item>Serbian (sr)</item>
      <item>Slovak (sk)</item>
      <item>Slovenian (sl)</item>
      <item>Swedish (sv)</item>
      <item>Ukrainian (uk)</item>
   </array>
</resources>

Sample colors.xml File

Posted on July 29, 2011
<?xml version="1.0" encoding="utf-8"?>
<resources>
	<color name="text_top_color">#00ff00</color>
	<color name="test_color">#FF0000</color>
</resources>

Sample dimens.xml File

Posted on July 29, 2011
<?xml version="1.0" encoding="utf-8"?>
<resources>
	<dimen name="text_top_size">22pt</dimen>
</resources>

Sample strings.xml File

Posted on July 29, 2011
<?xml version="1.0" encoding="utf-8"?>
<resources>
	<color name="text_top_color">#00ff00</color>
	<color name="test_color">#FF0000</color>
</resources>

Sample AndroidManifest.xml File

Posted on July 29, 2011
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sample.someapp"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" />

    <uses-permission android:name="android.permission.CAMERA"></uses-permission>

    <application android:label="@string/app_name" android:description="@string/app_desc"
    	android:icon="@drawable/quizicon" android:debuggable="true">
        <activity android:name=".QuizSplashActivity"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="QuizMenuActivity"></activity>
        <activity android:name="QuizHelpActivity"></activity>
        <activity android:name="QuizScoresActivity"></activity>
        <activity android:name="QuizSettingsActivity"></activity>
        <activity android:name="QuizGameActivity"></activity>

        <activity android:name="About"
        	android:label="@string/about_title"
        	android:theme="@android:style/Theme.Dialog" />
    
        <activity android:name="Prefs"
        	android:label="@string/settings_title" />
        	
        <activity android:name="Game"
        	android:label="@string/game_title" />
        	
        <activity android:name="Keypad"
        	android:label="@string/keypad_title" />

    </application>
</manifest>

Switch to our desktop site