Calling activity from inside a thread?

by Abhi » Thu, 18 Feb 2010 23:01:09 GMT


Sponsored Links
 Hi,

I want to either use WiFiManager to toggle wifi from inside a thread
or call another activity to do this, whichever is possible. I tried
using the wifimanager class inside the thread but it didn't work.
Could anyone tell me how to call an activity using Intents from inside
a thread?

Thanks,

Abhi

--



Calling activity from inside a thread?

by Abhi » Fri, 19 Feb 2010 03:39:59 GMT


 Hi,

I want to either use WiFiManager to toggle wifi from inside a thread
or call another activity to do this, whichever is possible. I tried
using the wifimanager class inside the thread but it didn't work.
Could anyone tell me how to call an activity using Intents from inside
a thread?

Thanks,

Abhi

--


Sponsored Links


Calling activity from inside a thread?

by Steeler » Fri, 19 Feb 2010 14:09:04 GMT


 Do you have a reference to the activity's context in your thread? If
so, I think you could do something like this:

Intent _intent = new Intent(yourContext, yourActivity.class);
yourContext.startActivity(_intent);

provided that yourActivity was declared in your manifest.




--



Other Threads

1. Resources.getDrawable() returning empty bitmap

I'm working on adding a map view to an app of mine, and so far I've
successfully gotten the MapView itself to work.  I'm trying to add an
overlay now, and I'm having problems loading the bitmap resources to
do that.

Here is the code snippet that does the loading, in the activity's
onCreate:
Resources res = getResources();
mCacheSym = res.getDrawable(R.drawable.symb_cache);
mFoundSym = res.getDrawable(R.drawable.symb_found);
mWptSym = res.getDrawable(R.drawable.symb_wpt);

(the m*Sym variables are all Drawable type)

The getDrawable calls seem to successfully return a BitmapDrawable,
but it's an empty bitmap... the height and width in the object are -1
and all 4 numbers in the bounds rectangle are 0.  The images are all
28x28 8-bit PNG, but I don't think that's the issue as I tried
replacing one of the IDs with an image I'm already using for a menu
item and it did the same thing.

Any ideas?
--~--~---------~--~----~------------~-------~--~----~

2. EditText not honoring width attribute

I have a table layout with multiple TableRow elements each with a
textView (prompt) and an editText element (input)
so my table looks something like below.  Unfortunately The layout is
honored such that all of the EditText fields expand so that all of
them are as big as the largest 1.  None of them are different from
each other even though they each have explicitly different widths.
How do I have them each get their own size definitions?


<TableLayout android:id="@+id/TableLayout01"
android:layout_width="fill_parent"
        android:layout_height="wrap_content">

<TableRow android:id="@+id/TableRow01"
android:layout_width="fill_parent"
        android:layout_height="wrap_content"
android:duplicateParentState="false">
        <TextView android:id="@+id/TextView01"
android:orientation="vertical"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Prompt 1:"
                android:paddingRight="20dip">
                </TextView>
        <EditText android:id="@+id/EditText01"
android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:width="180dip">
        </EditText>

</TableRow>
<TableRow android:id="@+id/TableRow02"
android:layout_width="fill_parent">
        <TextView android:id="@+id/TextView02"
android:orientation="vertical"
                android:layout_width="wrap_content"
android:layout_height="wrap_content"
                android:text="Prompt 2:" android:paddingRight="20dip">
                </TextView>

        <EditText android:id="@+id/EditText02"
                android:layout_width="wrap_content"
android:layout_height="wrap_content"
                android:width="50dip">
                </EditText>
</TableRow>
<TableRow>
        <TextView android:id="@+id/TextView03"
android:orientation="vertical"
                android:layout_width="wrap_content"
android:layout_height="wrap_content"
                android:text="Prompt 3"  android:paddingRight="20dip">
                </TextView>
        <EditText android:id="@+id/EditText03"
android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:width="50dip">
                </EditText>
</TableRow>

<TableRow android:id="@+id/TableRow03"
        android:layout_width="wrap_content"
android:layout_height="wrap_content">
        <TextView android:id="@+id/TextView04"
android:layout_width="wrap_content"
                android:layout_height="wrap_content">
                </TextView>
        <Button android:id="@+id/Button01"
android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:text="Run">
                </Button>

</TableRow>
</TableLayout>

--~--~---------~--~----~------------~-------~--~----~

3. how to make a custom view shown on home screen as AppWidget?

4. layout_alignBaseline doesn't work with Spinner?

5. Find whether any audio is currently playing

6. About RILD system

7. not loaded BT lib....