-2

I am developing an application that takes a number of tasks from user and reminds him on time.

So, I need to know how to run my application in the background and how to get the data from SQLite - Date&Time- to set the alarm.

The class of the task:

public class Task {
String name;
String discrb;
int day , month , year ,donecheck ,periocheck,hour,minute;
 public Task()
  {
name=discrb="";
donecheck =day=month=year=periocheck =0;    
  }
}
Mathias Müller
  • 22,203
  • 13
  • 58
  • 75
user3190285
  • 1
  • 1
  • 1

2 Answers2

3

Use service

Tutorial

Doc reference

Adam Radomski
  • 2,515
  • 2
  • 17
  • 28
0

Use below code.

public class MainActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Intent intent = new Intent(MainActivity.this, AppService.class);
        startService(intent);

        hideApp(getApplicationContext().getPackageName());
        System.out.println("Inside of main");
    }

    private void hideApp(String appPackage) {
        ComponentName componentName = new ComponentName(appPackage, appPackage
                + ".MainActivity");
        getPackageManager().setComponentEnabledSetting(componentName,
                PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                PackageManager.DONT_KILL_APP);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}
InnocentKiller
  • 5,234
  • 7
  • 36
  • 84