我希望當我的應用程序退出,退出後如果沒有任何操作在屏幕上執行5分鐘,每次都會播放視頻,此視頻ID在我的應用程序中定義。 任何幫助,將不勝感激。 Thankx提前。如何在沒有任何操作的情況下在Android屏幕上執行5分鐘的視頻播放?
我有以下的類,但它不能正常工作,如何可以使服務相同的代碼?
public class IdlePhoneState extends Activity {
Handler hl_timeout = new Handler();
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
try{
hl_timeout.postDelayed(DoOnTimeOut, 120000); // 2 min
}catch(Exception e)
{
e.printStackTrace();
}
}
// Toast
Thread DoOnTimeOut = new Thread() {
public void run() {
try{
Toast.makeText(getApplicationContext(), "System is idle", Toast.LENGTH_LONG).show();
}catch(Exception e)
{
e.printStackTrace();
}
}
};
@Override
public void onUserInteraction()
{
super.onUserInteraction();
//Remove any previous callback
try{
hl_timeout.removeCallbacks(DoOnTimeOut);
hl_timeout.postDelayed(DoOnTimeOut, 120000);
System.out.println("ggggggggggggggggggggg");
Intent intr= new Intent(getApplicationContext(), VideoPlayerActivity.class);
startActivity(intr);
}catch(Exception e)
{
e.printStackTrace();
}
}
}
說明你在尋找什麼!喜歡的東西**動態壁紙**? –
您可以使用服務於它,這將播放視頻在背景中。 – Piyush
我想要屏幕保護程序 – Khushboo