0
A
回答
2
看一看這樣的:
- http://developer.android.com/reference/android/content/BroadcastReceiver.html
- http://developer.android.com/guide/topics/manifest/receiver-element.html
寫在AndroidManifest.xml文件下面的代碼:
<receiver android:name=".appwidget.ExampleBroadcastReceiver" android:enabled="false">
<intent-filter>
<action android:name="android.intent.ACTION_TIMEZONE_CHANGED" />
<action android:name="android.intent.ACTION_TIME" />
</intent-filter>
</receiver>
並定義如下的類:
public class ExampleBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("ExmampleBroadcastReceiver", "intent=" + intent);
// For our example, we'll also update all of the widgets when the timezone
// changes, or the user or network sets the time.
String action = intent.getAction();
if (action.equals(Intent.ACTION_TIMEZONE_CHANGED)
|| action.equals(Intent.ACTION_TIME_CHANGED)) {
AppWidgetManager gm = AppWidgetManager.getInstance(context);
ArrayList<Integer> appWidgetIds = new ArrayList<Integer>();
ArrayList<String> texts = new ArrayList<String>();
ExampleAppWidgetConfigure.loadAllTitlePrefs(context, appWidgetIds, texts);
final int N = appWidgetIds.size();
for (int i=0; i<N; i++) {
ExampleAppWidgetProvider.updateAppWidget(context,
gm, appWidgetIds.get(i), texts.get(i));
}
}
}
}
並擁有WifiDemo例如, click Here。
+1
非常感謝Paresh。 – praveenb 2010-08-06 12:16:27
相關問題
- 1. 如何使用android廣播接收機
- 2. 廣播接收機android
- 3. 我怎樣才能收集
- 4. 我怎樣才能在android
- 5. 我的廣播接收機不能得到BOOT_COMPLETED廣播
- 6. 廣播接收機在IntentService
- 7. 我們只能使用一臺廣播接收機嗎?
- 8. 我怎樣才能在播放框架中使用lift-mongo-record?
- 9. Android的剪貼板廣播接收機
- 10. 的android廣播接收機通知
- 11. 廣播接收機空指針的Android
- 12. 關於廣播接收機android
- 13. 訪問使用廣播接收機
- 14. 廣播接收機問題
- 15. ConnectivityManager.CONNECTIVITY_ACTION廣播接收機
- 16. 在Windows 10手機中接收廣播
- 17. 怎樣才能讓android中
- 18. 我怎樣才能使PHP
- 19. 我怎樣才能在Android模擬器
- 20. 我們怎樣才能在Android 1.6的
- 21. 我怎樣才能在Android的
- 22. 我怎樣才能恢復在android
- 23. 我怎樣才能在android系統
- 24. 我怎樣才能在不使用硒
- 25. 廣播接收器功能的Android
- 26. 我怎樣才能
- 27. 在android中處理未接電話與廣播接收機
- 28. Android在ActionBarActivity中接收廣播
- 29. Android。廣播接收器
- 30. Android MMS廣播接收器
-1用於詢問需要2秒鐘的搜索時間才能找到 – Falmarri 2010-08-06 17:46:45
+1節省了我的搜索時間 – hwrdprkns 2011-12-29 08:26:16