I want to develop an application where it will start on particular time & close on particular time. Similar like Alarm but not alarm application. As per my thinking I will start an service when application first started service will check current time & particular timing to match the condition & when condition is to close application it will simply send application to background so that service will be running & when condition for wake up occurs service will bring application front. Is this possible? If yes please give an example links or anything helpful. Also I am trying to understand the service but it's little bit complex for me so if you have link which will help me to understand the service it will be very helpful. Thank You.
Problem Solved:
/*To close the activity/
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivity(intent);
MainActivity.this.finish();
OR Just finish activity;
MainActivity.this.finish();
/** To start the activity*/
Intent i = new Intent();
i.setAction(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ComponentName cn = new ComponentName(this, MainActivity.class);
i.setComponent(cn);
startActivity(i);
It worked for me still I if any one have better solution please post below.
Thank You