これは単純なはずですが、私は混乱しています。
IntentServiceイベントを介してメイン アクティビティからを開始し、イベントの同じメイン アクティビティ内の静的内部クラスを参照するonClickを使用して、サービスからの応答をリッスンします。PendingIntentBroadcastReceiveronClick
public void onClick(View arg0) {
Intent intent = new Intent(this, MyService.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this,0,MyReceiver,0);
startService(intent);
}
public static class MyReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
// Do stuff here ....
}
今、私がやりたいProgressBarのは、アクティビティの UI に (渦巻く不確定なもの) を表示することだけIntentServiceです。ProgressBar私はxmlで次のように定義しました
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.Holo.ProgressBar.Large"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:id="@+id/progress"
android:visibility="gone"/>
onClickイベントから開始できます
ProgressBar pb = (ProgressBar) findViewById(R.id.progress);
pb.setVisibity(View.VISIBLE);
しかし、どこにどのように隠すか迷っています??? 静的クラスとして実行できずmyReceiver、UI にアクセスできません。とても簡単に思えますが、最善の方法がわかりません。助言がありますか?
ありがとう!