phuc-n
10/6/2017 - 5:01 PM

Snippet_Android

        case android.R.id.home:
                // Navigate back to parent activity (CatalogActivity)
                NavUtils.navigateUpFromSameTask(this);
                return true;
Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            goToMarket.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY |
                    Intent.FLAG_ACTIVITY_NEW_DOCUMENT |
                    Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse(
                                "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName())));
            }
@Override public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof MyDate)) return false; // làm việc cả khi o là null.
    MyDate d = (MyDate) o;
    return day == d.day && month == d.month && year == d.year;
}

@Override public int hashCode() {
    return 31 * (31 * (31 * 11 + day) + month) + year;
}
public float average(int... nums) {
    int sum = 0;
    for (int x : nums) sum += x;
    return nums.length == 0 ? 0 : (float) sum / nums.length;
}
// Cover time to human readable format
// time ago

long now = System.currentTimeMillis();
DateUtils.getRelativeTimeSpanString(lastUpdated.getTime(), now, DateUtils.DAY_IN_MILLIS);