Reputation: 2342
I am working on Android app which have worked on TV devices,i want when i close my app,and if no one touch the mouse or keyboard,then my app is start automatically after x time duration,this is possible?if yes then please help,Thanks alot.
Upvotes: 0
Views: 231
Reputation: 715
Its Possible by using PendingIntent in your service.
http://developer.android.com/reference/android/app/PendingIntent.html
Upvotes: 0
Reputation: 5145
Yes it is possible U can take help from service just start one timerthread on Ondestroy() of your app means On last activity or u can perform this action on close of your app. Check with ideal state from thread if any broadcast from mouse or keyboard u will get then reset your timer thread according to it. When ever your timer thread reach at your time just start activity programmatic like
Intent i = Context.getPackageManager().getLaunchIntentForPackage(Context.getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addCategory(Intent.CATEGORY_HOME);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Context.startActivity(i);
Upvotes: 1