0

I want to test if a service will still run after lets say, 5 days has passed. I do not want to just set the phone's time, I want the phone to think that the time has passed so that it will get rid of background apps, etc.

How do I do that in adb?

theAnonymous
  • 1,701
  • 2
  • 28
  • 62

2 Answers2

0

I want the phone to think that the time has passed so that it will get rid of background apps, etc.

  • Android can actually finish your application only and not other app.
  • To get rid of background apps, you can use Task Manager but that's what manual process.
  • If you have background service running over 5 days, you can actually stop your service, use AlarmManager for it.

As your question is not properly clarified, there could be multiple solution to your problem, of which i have tried to address.

Zoombie
  • 3,590
  • 5
  • 33
  • 40
0

I use the following code in my app to get the current date:

    Calendar c = Calendar.getInstance();
    System.out.println("Current time => " + c.getTime());

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
    AndroidDate = df.format(c.getTime());

Now with that said, all you can do is set the AndroidExpiryDate (string) and set your own date of expiry:

AndroidExpiryDate = "2016-02-28"

Then you can just compare current date (AndroidDate) with expiry date (AndroidExpiryDate ) using if statement:

if ("AndroidDate".equals("AndroidExpiryDate") )
{
    //code to get rid of background app
}
user3560827
  • 632
  • 1
  • 5
  • 22