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. Android使廣播接收機安全
- 6. 我的廣播接收機不能得到BOOT_COMPLETED廣播
- 7. android-我怎樣才能使用「android:layoutDirection」?
- 8. Android的我怎樣才能使中風
- 9. 廣播接收機在IntentService
- 10. 在Android中使用服務和廣播接收機「經濟」在我的Android
- 11. 我們只能使用一臺廣播接收機嗎?
- 12. 我怎樣才能在播放框架中使用lift-mongo-record?
- 13. 我怎樣才能讓「controlLevelSwitch」在Serilog Seq接收器中工作
- 14. 我怎樣才能只接收目前可以使用的計算機名稱?
- 15. 我怎樣才能防止LogCat接收所有使我的手機?
- 16. 我怎麼能在廣播接收器發射片段
- 17. 訪問使用廣播接收機
- 18. 廣播接收機和ResultReceiver android
- 19. Android的剪貼板廣播接收機
- 20. 的android廣播接收機通知
- 21. 廣播接收機空指針的Android
- 22. 關於廣播接收機android
- 23. 壁紙更改廣播接收機android
- 24. Android廣播接收機始終運行
- 25. ConnectivityManager.CONNECTIVITY_ACTION廣播接收機
- 26. 廣播接收機問題
- 27. 我怎樣才能使PHP
- 28. 怎樣才能讓android中
- 29. 在Windows 10手機中接收廣播
- 30. 我怎樣才能在不使用硒
-1用於詢問需要2秒鐘的搜索時間才能找到 – Falmarri 2010-08-06 17:46:45
+1節省了我的搜索時間 – hwrdprkns 2011-12-29 08:26:16