Hi, I've been trying to get my progress bar view to work in my file scanner application, and I'm thoroughly stumped by the proper combination of Activities, Services, Threads, and Handlers.
Here's the structure: My Activity contains a Horizontal-styled ProgressBar. On menu item click, I spawn a Service which, onCreate(), which is where I want to be able to update the progress bar.
My question: what am I missing?
- Activity "a" (with ProgressBar)
2. "a".onOptionsItemSelected(): Spawn Service "b"
3. "b".onCreate(): Control the ProgressBar in "a" // here is where I have my trouble
Layout for Progress Bar (1):
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_height="wrap_content"
android:max="100"
android:progress="0"
android:secondaryProgress="0"
android:layout_width="300px"
android:layout_marginLeft="10px"
android:id="@+id/progress_horizontal"
/>
"a".onOptionsItemSelected (2):
public boolean onOptionsItemSelected(MenuItem item)
{
if (svc == null)
{
android.util.Log.v("@@@@@@@@@@@@@@@@@@@@@", "starting");
svc = new Intent(this, DoScan.class);
// done in "a".onCreate()
// hmap = new HashMap();
// hmap.put("tv", tv);
svc.putExtra("hmap", hmap);
startService(svc);
}
break;
}
"b".onCreate() (3):
@Override
public void onCreate() {
super.onCreate();
//startThread();
TextView tv = (TextView) Peekaboo.hmap.get("tv");
tv.append("cocktail");
}