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?
Thanks

--



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
 http://sites.google.com/site/rezmobileapps/treking 

--


Sponsored Links


Other Threads

1. Application gets killed due to a timeout

Hi,

since Cupcake our application became very unstable. It often dies and
users have to restart it manually. The log shows that it was killed
due to a timeout, something like this:

<code>
W/ActivityManager(   56): Timeout of broadcast BroadcastRecord
{434824c8 android.provider.Telephony.SMS_RECEIVED} -
receiver=android.os.binderpr...@434ba458
W/ActivityManager(   56): Receiver during timeout: ResolveInfo
{434663b8 com.websafety.android.client.SMSReceiver p=0 o=0 m=0x108000}
I/Process (   56): Sending signal. PID: 4702 SIG: 9
I/ActivityManager(   56): Process com.websafety.android.client (pid
4702) has died.
</code>

Previously it was working all fine. It also works fine on Emulator.
But it is extremely slow on HTC Magic. We found that sometimes it does
take some time to respond to some requests (such as the broadcast
above for Telephony.SMS_RECEIVED), while in other cases (for example,
we have a background Service which starts on BOOT_COMPLETED) it seems
the problem is not in our code. Previously, it was taking only 5
second for the service to start, while now it takes 15 seconds - the
same application, on the new Cupcake phone. I tried converting the
service onStart into a simple "new Thread().start()" - and guess what,
that gets killed as well before it reaches my first line of code. For
the cases when our code is "slow" it became much slower with Cupcake
(or is it HTC Magic?).

I guess I have two questions to Google, but if someone has workarounds
or similar experience please speak up:

1. Why is Cupcake so slow?
2. Can you document the expected time limits within which some
methods, either event listeners or overridden, should return before
they are considered timed out? We don't mind updating the application
by making sure we do respect those limits, but not knowing them costs
us too much money as we are discovering them through customer support
calls. The example methods which I suspect do have those limits are
Service.onStart, ContentObserver.onChange to name a few.

Thanks.

Denis
--~--~---------~--~----~------------~-------~--~----~

2. ListView inside LinearLayout inside ScrollView

I vaguely recall your earlier thread, so forgive me if I either repeat or
contradict myself, assuming I responded...


I would suspect that is a top-level LinearLayout, containing a
RelativeLayout for the logo/name/vendor/install status/rating, a ListView
for all the scrolling stuff, and a LinearLayout for the Open and Install
buttons.


Not the whole thing, but certainly the scrolling portion can be a
ListView. I'd be a bit surprised if it were done any other way.

The key is getViewTypeCount(), getItemViewType(), areAllItemsEnabled(),
and isEnabled() in your ListAdapter, plus returning appropriate views per
row in the list.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
Android App Developer Books: http://commonsware.com/books.html



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

3. things turning on in the night

4. why MotionEvent.ACTION_DOWN doesn't fire in onTouchEvent?

5. **never ever** use Toasts with Activity context

6. Android Maket Place Apps

7. Android Market :: Free application gets to top of pile on new release, paid app doesn't?