http://www.linux-mag.com/id/7778
On Jun 30, 9:02 pm, AUandroid <thevk...@gmail.com> wrote:
> thanks Jeremy, I will try the onresume option. A separate thread is
> not feasible.
>
> -vk
> On Jun 30, 1:23 am, Jeremy <jklei...@gmail.com> wrote:
>
> > Here's one crazy workaround, but I'm sure there's an easier way:
>
> > When your receiver get's set off, you can set a hidden boolean
> > preference (since they are global) and then start a simple dialog
> > activity saying you've lost connectivity. Starting the new activity
> > will call the original activity's onPause so when the dialog is
> > closed, onResume is called for the original activity (the one where
> > you want to change the layout. What I would do is in the onResume
> > method for that activity, I would check if the boolean preference was
> > changed and then change the visibility of the button accordingly. You
> > just have to make sure to set the preference back when you need the
> > button.
>
> > This is a pretty strange way to fix this problem, but it does work.
> > Are you sure you need a receiver for what you're doing though? I know
> > you can check connectivity pretty easily with a method like:
>
> > public boolean isConnected() {
> > ConnectivityManager connMgr=(ConnectivityManager)
> > getSystemService(Context.CONNECTIVITY_SERVICE);
> > NetworkInfo info=connMgr.getActiveNetworkInfo();
> > return(info!=null && info.isConnected());
> > }
>
> > but I guess if you want the button to be disabled instantly when
> > connection is lost, you'd have to be running that method in a separate
> > thread over and over, which is probably worse from an efficiency
> > standpoint than using a receiver.
>
> > On Jun 28, 9:13 pm, AUandroid <thevk...@gmail.com> wrote:
>
> > > I have a layout with two buttons, I want to disable or make unclikable
> > > one of the buttons when internet connection is lost and back to
> > > clickable when connection is regained. From my broadcast receiver I am
> > > calling another class(which extends activity and thus can call
> > > findViewById) which is attempting to change the main layout. App is
> > > force closing. What am I doing wrong here, any other ideas as to how
> > > to achieve what I am trying to do. thanks
>
> > > -vk
>
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment