3

放送受信機で壁紙変更イベントを取得できますか?ユーザーが壁紙を変更したかどうかを検出する必要があります。どうすればいいですか?

私がやっていることはこれです:私は壁紙を自動的に変更するアプリを持っています。ユーザーが別のアプリケーションを使用して手動で変更した場合は、それに気づき、その新しい壁紙をアプリケーションのリストに追加するかどうかをユーザーに尋ねます。

4

2 に答える 2

7

壁紙画像が変更された場合のブロードキャストのみがあります:http://developer.android.com/reference/android/content/Intent.html#ACTION_WALLPAPER_CHANGED

やりたいことを行うには、これを使用して壁紙が画像以外のものに変更されているかどうかを判断するためのロジックがさらに必要になります:http: //developer.android.com/reference/android/app/WallpaperManager.html# getWallpaperInfo()

正直なところ、変更される壁紙を作成する場合は、ライブ壁紙を作成することを検討する必要があります。これにより、システムにはるかに快適に適合します。表示内容をいつでも変更でき、ライブ壁紙が停止するため、ユーザーが別の壁紙を選択したことは明らかです。

また、ACTION_WALLPAPER_CHANGEDの使用には細心の注意を払う必要があります。これは、他のアプリケーションとの相互作用が悪くなる可能性があるためです。次のAPIに表示されるドキュメントは次のとおりです。

/**
 * Broadcast Action:  The current system wallpaper has changed.  See
 * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
 * This should <em>only</em> be used to determine when the wallpaper
 * has changed to show the new wallpaper to the user.  You should certainly
 * never, in response to this, change the wallpaper or other attributes of
 * it such as the suggested size.  That would be crazy, right?  You'd cause
 * all kinds of loops, especially if other apps are doing similar things,
 * right?  Of course.  So please don't do this.
 *
 * @deprecated Modern applications should use
 * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
 * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
 * shown behind their UI, rather than watching for this broadcast and
 * rendering the wallpaper on their own.
 */

実話。

于 2012-05-15T19:31:00.253 に答える
2

何も放送されないと思います。

WallpaperManagerには、現在の壁紙をドローアブルとして返すゲッターがいくつかあります。おそらく、現在のものを保存されているコピーと比較して、変更されているかどうかを判断できます。ただし、この機能を使用して、ユーザーが壁紙を設定した後で壁紙を変更してだましている場合は、知っておいてください。暗闇の中で素足でレゴを踏んでください。

于 2012-05-15T00:02:25.850 に答える