2010-07-28 132 views

回答

4

你需要聲明一個廣播監聽器監聽項值

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> 

在你的聽衆:

Intent myStarterIntent = new Intent(context, YOUR_CLASS_TO_START.class); 
/* Set the Launch-Flag to the Intent. */ 
myStarterIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
myStarterIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 
/* Send the Intent to the OS. */ 
context.startActivity(myStarterIntent); 

使用上述思路的另一個例子:auto start app

+0

我在夫妻倆嘗試過,但我的應用程序沒有啓動編輯在啓動.. – 2016-02-04 14:53:17

+1

如果你正在開始一項活動,上述將工作。對於服務,您將不得不調用startService()。如果您發現無法正常工作,則應將設備連接到計算機並觀看系統日誌。如果有權限問題或其他問題阻止它,它會顯示在那裏。 – ekawas 2016-02-04 15:17:25

相關問題