Groups
Groups
Sign in
Groups
Groups
日本Androidの会
Conversations
About
Send feedback
Help
ウィジェットのライフサイクルについて
521 views
Skip to first unread message
kenken
unread,
Oct 17, 2010, 1:26:55 AM
10/17/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 日本Androidの会
はじめまして、kenkenです。
初めて投稿します。
ウィジェットで、画面回転時および電源OFF時に処理をさせたいと思っています。
調べてみると、画面回転時にはonUpdate()メソッドがコールされるようなのですが、
自分の環境ではアプリインストール後、1回目の画面回転の時しかコールされません。
みなさんの環境ではどうなんでしょうか?
また、電源OFF時を検知したいのですが、いいんでしょうか?
環境:Emulator/Android SDK 2.2
ウィジェット:AppWidgetProviderクラス
を使用しています。
まだAndroidアプリ開発を始めたばかりで、
必要な情報がどこにあるのかも判っていない状態です。
御存知の方がいらっしゃいましたら、御教授お願い致します。
kenken
unread,
Oct 19, 2010, 5:57:53 AM
10/19/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 日本Androidの会
申し訳ありません。
日本語が間違っていました。
> また、電源OFF時を検知したいのですが、いいんでしょうか?
↓
また、電源OFF時を検知したいのですが、どのようにしたらいいんでしょうか?
よろしくお願いします。
Kou Kirishima
unread,
Oct 20, 2010, 2:38:14 AM
10/20/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 日本Androidの会
http://developer.android.com/intl/ja/reference/android/appwidget/AppWidgetManager.html#ACTION_APPWIDGET_UPDATE
上記ページによるとonUpdateがコールされるのは、
・AppWidgetPrividerにより初期化されたとき(Widgetが配置された場合や、再インストール時)
・update intervalで設定した時間が経過したとき
・端末が起動したとき
のようですので、画面回転ではコールされないと思います。
ちなみに過去に私が調べたところでは、Widgetで画面回転を検知する方法はない、との結論に至っています。
(あるなら、教えて欲しいですが・・・)
電源OFFについてはわかりませんが、同様に無理ではないでしょうか?
Kd
unread,
Oct 20, 2010, 8:41:26 PM
10/20/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to android-g...@googlegroups.com
Rと申します。
電源OFFの取得ですが、電源OFF時に
Intent.ACTION_SCREEN_OFF
のブロードキャストをだすので、僕はそれを受け取って処理をしています。
お役に立てればいいのですが。
kenken
unread,
Oct 21, 2010, 11:12:55 PM
10/21/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to 日本Androidの会
kenkenです。
Kou Kirishimaさん、Rさん、情報ありがとうございます。
> Kou Kirishimaさん
ウィジェットのアプリを公開されている方のサイトを調べていると、
複数のサイトで、画面回転時にonUpdate()がコールされると書かれてあったので、
動作確認をしていました。
しかし、リファレンスでは、画面回転時は該当していないんですね。
1回目の画面回転時にonUpdate()がコールされるのは、
実は違う条件(横向きレイアウトのインスタンス作成時?)だということなんですね。
ありがとうございました。
> Rさん
情報ありがとうございます。
早速、ACTION_SCREEN_OFFブロードキャスト受信に
挑戦しようと思います。
Reply all
Reply to author
Forward
0 new messages