I want to develop an application in which it will start at a certain time and close at a certain time. Similar to Alarm, but not Alarm. In my opinion, I started the service when the application that started the service for the first time checks the current time and the specific time to match the condition, and when the condition closes the application, it simply sends the application to the background so that the service works and when the condition for waking up is brings the application forward. Is it possible? If so, provide link examples or something useful. I am also trying to understand this service, but it is a little difficult for me, so if you have a link that will help me understand that it will be very useful. Thanks.
Problem resolved:
/ * To close 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 end the activity;
MainActivity.this.finish();
/ ** To get started * /
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);
This worked for me, if I have a better solution, please write below.
thanks
source share