When GPS information is not available-- how to handle it

by Sean » Wed, 17 Dec 2008 02:34:50 GMT


Sponsored Links
 We all know that GPS information is not always available (e.g., my GPS
lost its location information when it is inside a building).

If an application calls android location API to try to retrieve its
location information (when the GPS module can't report the
information, as described above), how should the application handle it
in general?

Thanks
Sean

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



Other Threads

1. problem in layout alignment

Hi all

I am new in android, i am having few problem in layout alignment.I
have divide the screen into three layout,as header, body and footer.

I am giving the height dynamically for the three layout in java file,
so i need to give 12% of height to header and footer layout, and the
remaining 75% i need to assign height to body layout.

For that i have made the calculation as follow

first i am getting the height and width for the screen. With the help
of the screen height i am getting the 12.5% height for header and
footer layout

WindowManager w = getWindowManager();
Display d = w.getDefaultDisplay();
int totalwidth_screen = d.getWidth();
int totalheight_screen = d.getHeight();


int total_HF_screen = (int) ((12.5/100)*totalheight_screen); # height
for header and footer
int total_body_screen = totalheight_screen - (2*(total_HF_screen))
#height for body

By assigning the width and height for the layout using the above
calculations, iam not getting the footer layout properly.i.e only some
part of the footer is viewable.

I need to assign the height for the layout dynamically, which is not
comming using the above calculation.Can you please suggest me the apt
way of calculation for dynamically assigning the height of the
layout.

I have mention the xml file and java file for your reference



Xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:id="@+id/widget0"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android" >

        <LinearLayout
        android:id="@+id/header_aboutus"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/header">
        </LinearLayout>

        <LinearLayout
        android:id="@+id/body_aboutus"
        android:layout_width="fill_parent"
        android:layout_height="1dip"
        android:background="@drawable/body">
        </LinearLayout>

        <LinearLayout
        android:id="@+id/footer_aboutus"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:background="@drawable/footer">

                <Button
                android:id="@+id/aboutUs_home_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/home_button" >
                </Button>

        </LinearLayout>

</LinearLayout>



java file

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class aboutus extends Activity {

        public String data;

        public void onCreate(Bundle icicle) {

                super.onCreate(icicle);
                setContentView(R.layout.aboutus);

                WindowManager w = getWindowManager();
            Display d = w.getDefaultDisplay();
            int totalwidth_screen = d.getWidth();
            int totalheight_screen = d.getHeight();


                int total_HF_screen = (int) ((12.5/100)*totalheight_screen);

                int total_body_screen1 =  2 * total_HF_screen;
                int total_body_screen = totalheight_screen - 
total_body_screen1;//
(int) ((75/100)* totalheight_screen);

               LinearLayout header_aboutus= (LinearLayout)
findViewById(R.id.header_aboutus);
                LinearLayout body_aboutus= (LinearLayout)
findViewById(R.id.body_aboutus);
                LinearLayout footer_aboutus= (LinearLayout)
findViewById(R.id.footer_aboutus);

                header_aboutus.setLayoutParams(
                                new LinearLayout.LayoutParams(totalwidth_screen,
total_HF_screen));
                body_aboutus.setLayoutParams(
                                new LinearLayout.LayoutParams(totalwidth_screen,
total_body_screen));
                footer_aboutus.setLayoutParams(new
LinearLayout.LayoutParams(totalwidth_screen, total_HF_screen ));

        }

}



Thanks
C.Rajesh

-- 

2. Extending Gallery to not auto-center selected view

I would like to either extend the existing Gallery view or create a
new view based on the code for the Gallery view that does not auto-
center the selected view.  What would be the cleanest/simplest way to
go about this?  It looks like all the methods of the Gallery view that
control the auto-centering of the children are private so extending
the class might be problematic.  I looked at starting with the code
for the Gallery view and the modifying it to give me the desired
effect but all the member variables that seem to be available to the
Gallery view are NOT available to me to access from my code... :(

I would love to hear what others have tried...

Mark

-- 

3. Unable to get android running on AT91SAM9G45

4. HTC Incredible, unified media content provider for internal/external storage

5. How can I access the images of a specific directory from sdcard

6. OOT WTA yg pake handset android garansi lokal siapa aja yak..

7. what happens exactly when android goes to sleep?