在特定的时间间隔调用实现意图

在特定的时间间隔调用实现意图

问题描述:

我想借助隐式意图从我的应用程序启动另一个应用程序,并希望第二个活动在特定的时间间隔后停止。在特定的时间间隔调用实现意图

对于如: 要打开铬我能做到这一点像

String url = "http://www.example.com"; 
    Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    i.setPackage("com.android.chrome"); 
    try { 
     startActivity(i); 
    } catch (ActivityNotFoundException e) { 
     // Chrome is probably not installed 
     // Try with the default browser 
     i.setPackage(null); 
     startActivity(i); 
    } 

但我希望Chrome浏览器自动获得1分钟后关闭。有没有办法做到这一点?

+0

YOu添加Handler,TimerTask,Runnable,任何形式的线程并添加一个时间间隔,postDelayed,sleep来添加延迟 – Zoe

是的,你可以杀死一个应用程序;首先,你必须要找到通过ActivityManager很喜欢这个答案正在运行的应用:

How to find the currently running applications programatically in android?

然后你就可以杀死它喜欢这里暗示:

How to kill all running applications in android?

虽然我和谷歌真的不推荐这> <