2017-04-15 62 views
0

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

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

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

回答

相关问题