Archive

Posts Tagged ‘applications’

Geek Hero Comic

January 27, 2013 1 comment

Welcome to Geek Hero Comic,

Even though the series is under break, and no-one knows when it will come back again, but still, Geek Hero Comic is one of the best comic series about computer geeks.

If you’re already familiar or don’t know about it, just read it once, you will fall in love with it and keep reading every single interesting chapter.

[ Geek Hero Comic ]

version: 1.1

support Android version: 1.6+

Download: Play Store

[ Changelog ]

27/Jan/2013

[version 1.1]

.improve image quality when read in fullscreen mode
.add detailed information for characters

25/Jan/2013

[version 1.0]
.first release
.set GeekHero picture to wallaper
.read story from the very first episode to the last
.view image in fullscreen
.share episode to other apps, like Twitter, Facebook,…
.smooth image view
.add characters’ info

[ Features ]

information on series’ characters

. set wallpapers of some nice GeekHero pictures.

. read and load all chapters at the same time

. support reading in fullscreen mode

. start reading from last read chapter.

. smooth image viewer

[ Screenshots ]

screenshot_03screenshot_04screenshot_05

 

 

 

 

 

 

 

 

 

 

Cheers,

Pete Houston

DotA Killing Tracks v1.1 (updated)

July 11, 2011 1 comment

Ever been playing DotA, every player enjoys its killing sound tracks. It’s just like so fun after all, well, something like: First blood, Monster Kill!!!!!!!, Holy Shiiiiiiiiiiit!, RAMPAAAAAAAGE….

Application: DotA – Killing Tracks

Version: 1.1

Android version: 1.6+

Screenshots:

DotA Killing Tracks

DotA Killing Tracks 01

DotA Killing Tracks

DotA Killing Tracks 02

Descriptions:

– This application just plays a killing sound according to its kind.

Features:

– When you click any sound-track, it will be registered to system automatically. You can set your Incoming Call Ringstone, Notification Ringstone or whatever Ringstone …. enjoy the fun =))

Download: APK File

Credits:

IceFrog and PlayDota.Com for these cool sound-tracks and the funny background (forget the painter of this image, may you remind me?).

Change Log:

[ 2011 – July – 11 ]

+ first release v1.0

[ 2011 – July – 12 ]

+ next release with ringstone feature 🙂

[ 2011 – July – 13 ]

+ fix bug that duplicates ringstone in some droids.

+ add new icon to application.


Hope you like it! Enjoy the sound and hahahaha….

Cheers,

Pete Houston

Capture Emulator Screen (using DDMS)

June 27, 2011 1 comment

There is a supported function in capturing screen of Android Emulator. Today, one of my colleagues told me, I was so surprised and got so sicked of the every past days, I took screenshots by Windows screen capture function, then cropping image using MS-Paint. Couldn’t believe this!!!!

Oh well, it’s on DDMS, just access menu Device->Screen Capture, and things are automatically.

DDMS: Screen Capture

DDMS: Screen Capture

I’d like to share to everyone of you, so you don’t do stupid things like I did.

Hope you like it!

 

Cheers,

Pete Houston

 

Retrieve list of installed applications

June 12, 2011 3 comments

Hot quick simple tricks to query list of installed applications

	public static List<ApplicationInfo> getInstalledApplication(Context c) {
		return c.getPackageManager().getInstalledApplications(PackageManager.GET_META_DATA);
	}

Enjoy it!

Cheers,
Pete Houston

Custom grid view of applications

June 12, 2011 24 comments

Today, I’ll guide you how to create a simple grid view that displays the list of applications, look at screenshot below:

Application Grid Screenshot

Application Grid Screenshot

Similar to ListView, the GridView is the view control that displays its items like a grid, so you just need to work around similar to the PhoneBook ListView in my previous post.

A – Create the Project

Project Name: Application Grid

Application Name: Application Grid

Build Target: Android 2.3.3

Package Name: pete.android.study

Create Activity: MainActivity

Min SDK: 10

B – Sketch the Layout

Like the list view, we all need to construct 2 layout:

+ one layout for each item inside the grid

+ one layout for the main grid view display

1. Grid Item Layout

Very simple, we create one image view to display application icon and one text view to display application name.

Put this file: layout_appinfo.xml into /res/layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center_horizontal"
  >

  <ImageView
      android:id="@+id/ivIcon"
      android:layout_width="48dip"
      android:layout_height="48dip"
      android:scaleType="centerCrop"
  />
  <TextView
  	  android:id="@+id/tvName"
  	  android:layout_width="72dip"
  	  android:layout_height="wrap_content"
  	  android:gravity="center"
  	  android:textStyle="bold"
  />

</LinearLayout>

Remember to set image view “android:scaleType=”centerCrop”” to make image bitmap fit into the box. Also, set text alignment to “center” to make it display nicely with top icon.

2. Main Layout

Just put a grid view inside. Put this file main.xml into /res/layout

<?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"
    >

	<GridView
		android:id="@+id/gvMain"
		android:layout_width="fill_parent"
		android:layout_height="wrap_content"
		android:numColumns="4"
		android:columnWidth="72dip"
		android:gravity="center"
		android:stretchMode="columnWidth"
		android:padding="10dip"
		android:verticalSpacing="10dip"
		android:horizontalSpacing="10dip"
	/>

</LinearLayout>

C – Class Design: On the Idea

Application Grid: Class Diagram

Application Grid: Class Diagram

D – From Design to Coding

1. AppInfo: (AppInfo.java)  the entity class which holds information of application including: application icon and application name.

package pete.android.study;

import android.graphics.Bitmap;

public class AppInfo {
	private Bitmap mIcon;
	private String mName;

	public AppInfo(Bitmap icon, String name) {
		mIcon = icon;
		mName = name;
	}

	public void setIcon(Bitmap icon) {
		mIcon = icon;
	}
	public Bitmap getIcon() {
		return mIcon;
	}

	public void setName(String name) {
		mName = name;
	}
	public String getName() {
		return mName;
	}

}

2. AppInfoAdapter: (AppInfoAdapter.java) the adapter to handle the list of application info in the grid view.

package pete.android.study;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class AppInfoAdapter extends BaseAdapter {
	private Context mContext;
	private List<AppInfo> mListAppInfo;

	public AppInfoAdapter(Context context, List<AppInfo> list) {
		mContext = context;
		mListAppInfo = list;
	}

	@Override
	public int getCount() {
		return mListAppInfo.size();
	}

	@Override
	public Object getItem(int position) {
		return mListAppInfo.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		AppInfo entry = mListAppInfo.get(position);

		if(convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.layout_appinfo, null);
		}

		ImageView ivIcon = (ImageView)convertView.findViewById(R.id.ivIcon);
		ivIcon.setImageBitmap(entry.getIcon());

		TextView tvName = (TextView)convertView.findViewById(R.id.tvName);
		tvName.setText(entry.getName());

		return convertView;
	}
}

3. MainActivity: (MainActivity.java) the entry point to the application

package pete.android.study;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.widget.GridView;

public class MainActivity extends Activity {

	private GridView mGridMain;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mGridMain = (GridView)findViewById(R.id.gvMain);
        Resources res = getResources();
        List<AppInfo> listAppInfo = new ArrayList<AppInfo>();
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_browser), "Internet"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_clock), "Clock"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_display), "Display"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_favorite), "Favorite"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_home), "Home"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_mail), "Mail"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_media), "Media"));
        mGridMain.setAdapter(new AppInfoAdapter(this, listAppInfo));

    }
}

E – Note

– For the layout of each item in the grid view, if the LinearLayout you don’t set “android:gravity=”center_horizontal”“, then it will display very ugly.

– Make sure you put your application bitmap into /drawble

– Try to practice with this kind of simple application to understand the idea of Adapter in GridView, and ListView in my previous post.

– Think about design when u’re good at coding.

F – Get the Sample Project by Pete

Pick your favorite server: Mediafire | Rapidshare | FreeFileHosting | Megaupload

G – Final Words

– Have you learned something?

– Hope you enjoy it!

– Feel free to ask, comment, and suggest below; you’re all welcomed!

H – Update on Request

1. Alfox on request to add extra click event for GridView

– Since this is a GridView so we need to implement AdapterView.OnItemClickListener, and it must be set to GridView object, and not in the Adapter. This is a common mistake when people try to implement ClickListener on the Adapter!

– Here I will add this listener to add functionality that a Toast is displayed with the item name when users click on an item of GridView. It requires some changes for above source code, like below:

(1) Update the AppInfoAdapter class (AppInfoAdapter.java) to have a ViewHolder pattern which will cache data.

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		AppInfo entry = mListAppInfo.get(position);
		ViewHolder holder = null;

		if(convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.layout_appinfo, null);
			holder = new ViewHolder();
			holder.ivIcon = (ImageView)convertView.findViewById(R.id.ivIcon);
			holder.tvName = (TextView)convertView.findViewById(R.id.tvName);
			convertView.setTag(holder);
		}
		else {
			holder = (ViewHolder)convertView.getTag();
		}

		holder.ivIcon.setImageBitmap(entry.getIcon());
		holder.tvName.setText(entry.getName());

		return convertView;
	}

	static class ViewHolder {
		ImageView ivIcon;
		TextView tvName;
	}

(2) Add listener to the GridView and implement the listener to display information to Toast view.

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mGridMain = (GridView)findViewById(R.id.gvMain);
        Resources res = getResources();
        List<AppInfo> listAppInfo = new ArrayList<AppInfo>();
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_browser), "Internet"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_clock), "Clock"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_display), "Display"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_favorite), "Favorite"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_home), "Home"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_mail), "Mail"));
        listAppInfo.add(new AppInfo(BitmapFactory.decodeResource(res, R.drawable.app_media), "Media"));
        mGridMain.setAdapter(new AppInfoAdapter(this, listAppInfo));

        mGridMain.setOnItemClickListener(mItemClickListener); // add a ItemClickListener

    }
    // our handle for listener
    private OnItemClickListener mItemClickListener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> parent, View view, int pos, long id) {
			ViewHolder holder = (ViewHolder)view.getTag();
			if(holder == null) {
				return;
			}
			Toast.makeText(MainActivity.this, "You have clicked on item '" + holder.tvName.getText() + "'", Toast.LENGTH_SHORT).show();
		}
	};

(3) Rebuild and run your application…free to click on GridView item to see how it works!!!

 

Hope you enjoy it!

Cheers,

Pete Houston