view -> parent activity

by Andrei » Thu, 22 Apr 2010 13:17:03 GMT

Sponsored Links
 If I have reference to a view that is on activity
How do I get reference to the activity from view reference?


view -> parent activity

by ~ TreKing » Thu, 22 Apr 2010 22:05:19 GMT


You don't - at least not without maintaining your own mapping or holding a
reference somewhere yourself.
I guess you COULD put the Activity reference in the view's tag ... but that
seems dirty.
Why do you need an Activity? Most everything you need is usually available
from Context, which a view has.

TreKing - Chicago transit tracking app for Android-powered devices 


Sponsored Links

Other Threads

1. Using GPS in a widget hangs on lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, (float) 0.001, locationListener);

I need location updates in a widget.
The code below hangs in the emulator. Even if I change lat in emulator-
control, it stays hung.

Aside: The code works in a normal app.

Any help appreciated!

    public void onUpdate(Context context, AppWidgetManager
            int[] appWidgetIds) {

        final LocationManager lm=

        final LocationListener locationListener= new
LocationListener() {
            public void onLocationChanged(Location newloc) {
                    Log.d("TAG","onLocation Changed");
            public void onProviderDisabled(String provider) {}
            public void onProviderEnabled(String provider) {}
            public void onStatusChanged(String provider, int status,
                        Bundle extras) {}

        Log.d("TAG","gets here");

        lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
(float) 0.001, locationListener);

        Log.d("TAG","never gets here");


2. Thanks to Bro Daniel the Android enthusiast

Brow Lesjaw...

Terimakasih menyempatkan waktu utk bertemu kami...

Senang sekali. Belajar banyak langsung sama suhu.
Sedih melihat bekas gempa Padang tapi semangat lihat semua sedang
membangun kembali.

Kami tidak boleh terlalu lama di Padang. App Task Killer utk
kolesterol selalu shut down pas lagi makan enak....;)

Semoga dlm waktu dekat kita ketemu lagi.


3. Virtual Walkie Talkie App

4. What is difference between intent and pending intent ?

5. Siap Dikirim : Buku "membuat aplikasi untuk Android"

6. Upgrade HTC HERO

7. Soft Home, Menu, Back keys in status bar