如果用戶銷燬我的應用程序,我希望自動打開我的應用程序。如何創建此應用程序。我不知道如何創建此應用程序請任何人幫助我..如何在android中關閉應用程序時使用某些時間間隔?
-1
A
回答
1
使用AlarmManager:
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// Replace MyActivity.class with the activity class you want to run periodically
Intent i = new Intent(context, MyActivity.class);
PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
long now = System.currentTimeMillis();
long interval = 60 * 60 * 1000; // one hour
am.setRepeating(AlarmManager.RTC_WAKEUP, now, interval, pi);
而且,這個權限添加到您的AndroidManifest.xml:
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
0
您可以做的是使用後臺服務。從服務 您可以根據需要啓動您的應用程序。
使用該服務從
Intent intent = new Intent(getBaseContext(), myActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(intent);
服務參考 http://www.vogella.com/articles/AndroidServices/article.html
0
相關問題
- 1. Android Chromium WebView應用程序在某個時間後關閉
- 2. 在特定時間間隔關閉android應用程序的有效方法
- 3. 如何在應用程序關閉時管理時間?
- 4. 關閉應用程序的時間
- 5. 在黑莓中的特定時間間隔後關閉後臺應用程序
- 6. 如何在Windows中關閉應用程序時間表?
- 7. 如何在應用程序引擎中設置時間間隔
- 8. 如何在特定時間關閉通知,即使應用程序已關閉
- 9. 如何使某個應用程序在某些特定時間後卸載
- 10. Android - 即使在關閉應用時計算背景時間
- 11. 應用程序關閉一段時間後android
- 12. c3p0導致應用程序在偶發時間間隔超時
- 13. 如何跟蹤mfc應用程序關閉的時間?
- 14. 如何讓應用程序打開和關閉時間
- 15. android:在某些特定時間間隔內報警remian停止
- 16. 在某些時間間隔的Linux函數調用
- 17. 如何在Android應用程序中停止應用程序時關閉gps
- 18. 在iOS應用程序中計算時間間隔
- 19. 如何在Android中給定的時間間隔後關閉相機?
- 20. Android:使用線程在指定時間執行某些操作
- 21. 在特定時間在後臺關閉應用程序
- 22. 退出時應用程序關閉Android
- 23. android:在某些時間做某事
- 24. 定時時間間隔 - 應用程序池設置
- 25. 在Android應用程序CountUp時間
- 26. 如何檢測某些應用程序是否工作一定的時間間隔
- 27. 在一段時間後關閉應用程序後
- 28. 應用程序在很長一段時間後意外關閉
- 29. WPF應用程序在一段時間後自動關閉
- 30. android:報警任務在應用程序關閉時關閉
你到目前爲止做了什麼? – user2652394
你不覺得你想要做的是讓用戶惱火嗎? – hepizoj