Thursday, August 15, 2013

How to avoid having my app shown in the list of recently used apps in Android

How to avoid having my app shown in the list of recently used apps in Android

You have to add android:excludeFromRecents="true" to the activity in your AndroidManifest.xml

Sample code:

<activity
        android:label="@string/your_app_name_goes_here"
        android:excludeFromRecents="true"
        android:name=".SomeActivityNameGoesHere" >
        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

How to compare dates in Java

Date comparison in java:

                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date1 = sdf.parse("2009-12-31");
        Date date2 = sdf.parse("2009-12-31");

        System.out.println(sdf.format(date1));
        System.out.println(sdf.format(date2));

        if(date1.after(date2)){
        System.out.println("Date1 is after Date2");
        }

        if(date1.before(date2)){
        System.out.println("Date1 is before Date2");
        }

        if(date1.equals(date2)){
        System.out.println("Date1 is equal Date2");
        }