Trying to predict if network is slow based on network type is incorrect - a
poor wifi connection can be really slow

It is better to just keep it simple and let the user always know the actual
progress without worrying about what the network speed is.

2011/12/14 Kostya Vasilyev <kmans...@gmail.com>

> As useful as this code is....
>
> .... what if the phone switches from EDGE to HSPA right after the user
> clicks "Login"?
>
> What if it switches from WiFi to GPRS?
>
> Try to predict the network is somewhat useful, but it's really a
> Schrodinger's Cat type of thing :)
>
> Since network conditions can vary rapidly and dramatically, I'd
> recommend making sure there is a good UI with clear progress
> indication, timeout, and maybe a cancel button.
>
> -- Kostya
>
> 14 декабря 2011 г. 15:49 пользователь Yahel <kaye...@gmail.com> написал:
> > Not exactly what you ask for but this is how I do it.
> >
> > I'm not trying to be specific about the speed in kbs of the connection
> > because it can change a lot due to the user moving from cell to cell.
> > So I simply detect what kind of mobile connection we are on and send a
> > slow connection warning only when connected via EDGE or GPRS.
> >
> > Here is the code that returns true if the connection is a slow one :
> >
> >        public boolean internetConnectionIsLowSpeed() {
> >                ConnectivityManager connec = (ConnectivityManager)
> > getSystemService(Context.CONNECTIVITY_SERVICE);
> >
> >                if (connec.getActiveNetworkInfo()==null) return(false);
> >
> >
> >                if
> > (connec.getActiveNetworkInfo().getType()==ConnectivityManager.TYPE_WIFI)
> > {
> >                        return(false);
> >                }
> >
> >                if
> >
> (connec.getActiveNetworkInfo().getType()==ConnectivityManager.TYPE_MOBILE)
> > {
> >
> >
>  switch(connec.getActiveNetworkInfo().getSubtype()) {
> >                                case TelephonyManager.NETWORK_TYPE_GPRS :
> return(true);
> >                                case TelephonyManager.NETWORK_TYPE_EDGE :
> return(true);
> >                                case TelephonyManager.NETWORK_TYPE_UMTS :
> return(false);
> >                                case
> TelephonyManager.NETWORK_TYPE_UNKNOWN : return(false);
> >                                default : return(false);
> >
> >                        }
> >                }
> >
> >                return(false);
> >        }
> >
> > --
> > 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+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
>
> --
> 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+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to