Make Them Fall, Unity3D Sample Game

Standard

Make Them Fall is a challenging game that requires multitasking capability. Control 2 falling players and let them fall as far as possible without touching any obstacle.

I redesigned Make Them Fall Game using Unity3D and you can access source code as a unity tutorial material at my Github account:

https://github.com/mirhoseini/makethemfall

Brain Rush, Unity3D Sample Game

Standard

Brain Rush is a super simple to play and gets very addictive. Just hold or release the screen to shift to either a square or circle and match the incoming shapes. The higher your score, the faster they come!

I redesigned Brain Rush Game using Unity3D and you can access source code as a unity tutorial material at my Github account:

https://github.com/mirhoseini/brainrush

How to access a Bit.ly short-link stats created by someone else?

Standard

Bitly is one of the best URL shortening service with a powerful counter and statistics and also allow you to use your own domain with a DNS pointed to bitly.

You can access your own short-links statistics in your profile and simply by just adding a + at the end of the billy link you can access other users’ links statistics.

 

here is a sample:

https://bitly.com/moba_zi  :arrow:  https://bitly.com/moba_zi+

billy Screen Shot

How to connect your activity to its fragment

Standard

Often you will want one Fragment to communicate with its Activity also all Fragment-to-Fragment communication must be done through the associated Activity. Two Fragments should never communicate directly.

Define an Interface
To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity.

public class HeadlinesFragment extends ListFragment {
    OnHeadlineSelectedListener mCallback;

    // Container Activity must implement this interface
    public interface OnHeadlineSelectedListener {
        public void onArticleSelected(int position);
    }

    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        
        // This makes sure that the container activity has implemented
        // the callback interface. If not, it throws an exception
        try {
            mCallback = (OnHeadlineSelectedListener) activity;
        } catch (ClassCastException e) {
            throw new ClassCastException(activity.toString()
                    + " must implement OnHeadlineSelectedListener");
        }
    }
    
    ...
}

Now the fragment can deliver messages to the activity by calling the onArticleSelected() method (or other methods in the interface) using the mCallback instance of the OnHeadlineSelectedListener interface.

Implement the Interface
In order to receive event callbacks from the fragment, the activity that hosts it must implement the interface defined in the fragment class.

public static class MainActivity extends Activity
        implements HeadlinesFragment.OnHeadlineSelectedListener{
    ...
    
    public void onArticleSelected(int position) {
        // The user selected the headline of an article from the HeadlinesFragment
        // Do something here to display that article
    }
}

 

full version at:
http://developer.android.com/training/basics/fragments/communicating.html

How to manage your Android Application Settings

Standard

Here is my best practice for managing your Android application settings using AppSettings class. by using this class you can save your different variables in shared preferences and also load them to ram when ever needed and use them in memory.

String methods sample:

AppSettings.setValue(this, KEY_NAME, name);
AppSettings.getString(this, KEY_NAME, "");
AppSettings.clearValue(this, KEY_NAME);