liuyuqi-dellpc 5 years ago
commit
737e40cee5

+ 9 - 0
.classpath

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>

+ 3 - 0
.gitignore

@@ -0,0 +1,3 @@
+/gen
+/bin
+/.settings

+ 33 - 0
.project

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>BaiduLocDemo</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 70 - 0
AndroidManifest.xml

@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.baidu.baidulocationdemo"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="15" />
+
+  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.READ_PHONE_STATE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.READ_LOGS" >
+    </uses-permission>
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
+
+    <application
+        android:name="com.baidu.baidulocationdemo.LocationApplication"
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@android:style/Theme.Black"
+         >
+        <service
+            android:name="com.baidu.location.f"
+            android:enabled="true"
+            android:process=":remote" >
+            <intent-filter>
+                <action android:name="com.baidu.location.service_v2.2" >
+                </action>
+            </intent-filter>
+        </service>
+
+        <!-- meta-data需要写在application中 -->
+        <meta-data
+            android:name="com.baidu.lbsapi.API_KEY"
+            android:value="请输入AK" />
+        <activity
+            android:name="com.baidu.baidulocationdemo.MainActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity android:name="com.baidu.baidulocationdemo.LocationActivity" >
+        </activity>
+        <activity android:name="com.baidu.baidulocationdemo.NotifyActivity"></activity>
+        <activity android:name="com.baidu.baidulocationdemo.QuestActivity"></activity>
+    </application>
+
+</manifest>

BIN
ic_launcher-web.png


BIN
libs/android-support-v4.jar


BIN
libs/arm64-v8a/liblocSDK6.so


BIN
libs/armeabi-v7a/liblocSDK6.so


BIN
libs/armeabi/liblocSDK6.so


BIN
libs/locSDK_6.03.jar


BIN
libs/mips/liblocSDK6.so


BIN
libs/mips64/liblocSDK6.so


BIN
libs/x86/liblocSDK6.so


BIN
libs/x86_64/liblocSDK6.so


+ 20 - 0
proguard-project.txt

@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}

+ 14 - 0
project.properties

@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-21

BIN
res/drawable-hdpi/ic_launcher.png


BIN
res/drawable-mdpi/ic_launcher.png


BIN
res/drawable-xhdpi/ic_launcher.png


BIN
res/drawable-xxhdpi/ic_launcher.png


+ 16 - 0
res/layout/activity_main.xml

@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".MainActivity" >
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/hello_world" />
+
+</RelativeLayout>

+ 21 - 0
res/layout/function_list.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/textView1"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:text="百度定位sdk产品Demo"
+        android:textAppearance="?android:attr/textAppearanceLarge" />
+
+    <ListView
+        android:id="@+id/functionList"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" >
+    </ListView>
+
+</LinearLayout>

+ 166 - 0
res/layout/geofence.xml

@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="244dp"
+        android:layout_weight="0.01"
+        android:orientation="horizontal" >
+
+        <LinearLayout
+            android:layout_width="195dp"
+            android:layout_height="wrap_content"
+            android:orientation="vertical" >
+
+            <LinearLayout
+                android:layout_width="150dp"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal" >
+
+                <TextView
+                    android:id="@+id/textView1"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="围栏id"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <EditText
+                    android:id="@+id/geoid"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:ems="10"
+                    android:text="geofence" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal" >
+
+                <TextView
+                    android:id="@+id/textView2"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="经度"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <EditText
+                    android:id="@+id/geolontitude"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    
+                    android:text="116.313122" >
+
+                    <requestFocus />
+                </EditText>
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal" >
+
+                <TextView
+                    android:id="@+id/TextView02"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="纬度"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <EditText
+                    android:id="@+id/geolatitude"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    
+                    android:text="40.047951" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="vertical" >
+
+                <TextView
+                    android:id="@+id/TextView01"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="围栏持续时间(ms)"
+                    android:textAppearance="?android:attr/textAppearanceMedium" />
+
+                <EditText
+                    android:id="@+id/geoduration"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    android:inputType="numberDecimal"
+                    android:text="36000000" />
+
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal" >
+
+                <Button
+                    android:id="@+id/addfence"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="添加围栏" />
+
+                <Button
+                    android:id="@+id/removefence"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="删除围栏" />
+
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical" >
+
+            <ListView
+                android:id="@+id/geolist"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent" >
+            </ListView>
+
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="0.05"
+        android:orientation="vertical" >
+
+        <TextView
+            android:id="@+id/textView3"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="日志:"
+            android:textAppearance="?android:attr/textAppearanceLarge" />
+
+        <TextView
+            android:id="@+id/geofencelog"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:text=" "
+            android:textAppearance="?android:attr/textAppearanceLarge" />
+
+    </LinearLayout>
+
+</LinearLayout>

+ 175 - 0
res/layout/location.xml

@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/textView1"
+        android:layout_width="match_parent"
+        android:layout_height="200dp"
+        android:layout_weight="2.89"
+        android:scrollbars="vertical"
+        android:maxLines="12"
+        android:textColor="#ffffffff"
+        android:text=" "/>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:orientation="vertical" >
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal" >
+
+            <LinearLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:orientation="vertical" >
+
+                <TextView
+                    android:id="@+id/textView2"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text=" 定位模式"
+                    android:textAppearance="?android:attr/textAppearanceLarge" />
+
+		<RadioGroup
+		    android:id="@+id/selectMode"
+		    android:layout_width="wrap_content"
+		    android:layout_height="match_parent" >
+
+     		 <RadioButton
+     		     android:id="@+id/radio_hight"
+     		     android:layout_width="wrap_content"
+     		     android:layout_height="wrap_content"
+     		     android:checked="true"
+     		     android:text="高精度" />
+
+                <RadioButton
+                    android:id="@+id/radio_low"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="低功耗" />
+
+                <RadioButton
+                    android:id="@+id/radio_device"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="仅设备" />
+</RadioGroup>
+              
+            </LinearLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:orientation="vertical" >
+
+                <TextView
+                    android:id="@+id/TextView01"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="坐标系"
+                    android:textAppearance="?android:attr/textAppearanceLarge" />
+	<RadioGroup
+		    android:id="@+id/selectCoordinates"
+		    android:layout_width="wrap_content"
+		    android:layout_height="match_parent" >
+
+                <RadioButton
+                    android:id="@+id/radio_gcj02"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:checked="true"
+                    android:text="gcj02(国测局加密经纬度坐标)" />
+
+                <RadioButton
+                    android:id="@+id/radio_bd09ll"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="bd09ll(百度加密经纬度坐标)" />
+
+                <RadioButton
+                    android:id="@+id/radio_bd09"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="bd09(百度加密墨卡托坐标)" />
+</RadioGroup>
+            </LinearLayout>
+
+        </LinearLayout>
+
+        <TextView
+            android:id="@+id/modeinfor"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="2.88"
+            android:text=" " />
+
+        <LinearLayout
+            android:layout_width="278dp"
+            android:layout_height="wrap_content"
+            android:orientation="horizontal" >
+
+            <TextView
+                android:id="@+id/textView3"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="定位时间间隔(ms):"
+                android:textAppearance="?android:attr/textAppearanceLarge" />
+
+            <EditText
+                android:id="@+id/frequence"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:ems="10"
+                android:hint="1000"
+                android:inputType="number" >
+
+                <requestFocus />
+            </EditText>
+
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="2.89"
+            android:orientation="horizontal" >
+
+            <TextView
+                android:id="@+id/geofencelog"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:text="反地理编码"
+                android:textAppearance="?android:attr/textAppearanceLarge" />
+
+            <CheckBox
+                android:id="@+id/geolocation"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text=" " />
+        </LinearLayout>
+
+    </LinearLayout>
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_weight="2.89"
+        android:gravity="center|top"
+        android:orientation="vertical" >
+
+        <Button
+            android:id="@+id/addfence"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="开启定位" />
+
+    </LinearLayout>
+
+</LinearLayout>

+ 20 - 0
res/layout/notify.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical" >
+
+    <TextView
+        android:id="@+id/textView1"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="将我当前位置设置为提醒"
+        android:textAppearance="?android:attr/textAppearanceLarge" />
+
+    <Button
+        android:id="@+id/notifystart"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="开启位置提醒" />
+
+</LinearLayout>

+ 56 - 0
res/layout/quest_activity.xml

@@ -0,0 +1,56 @@
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" >
+
+    <RelativeLayout
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:paddingBottom="@dimen/activity_vertical_margin"
+        android:paddingLeft="@dimen/activity_horizontal_margin"
+        android:paddingRight="@dimen/activity_horizontal_margin"
+        android:paddingTop="@dimen/activity_vertical_margin"
+        tools:context=".MainActivity" >
+
+        <TextView
+            android:id="@+id/main_title"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:gravity="center_horizontal"
+            android:text="@string/qa_title"
+            android:textSize="@dimen/main_title_size" />
+
+        <TextView
+            android:id="@+id/error_code_title"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/main_title"
+            android:text="@string/error_code_desc"
+            android:textSize="@dimen/main_title_size" />
+
+        <TextView
+            android:id="@+id/error_code_content"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/error_code_title"
+            android:text="@string/error_code_detail"
+            android:textSize="@dimen/main_title_size" />
+
+        <TextView
+            android:id="@+id/call_back_title"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/error_code_content"
+            android:text="@string/qa_callback"
+            android:textSize="@dimen/main_title_size" />
+
+        <TextView
+            android:id="@+id/call_back_content"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:layout_below="@id/call_back_title"
+            android:text="@string/qa_callback_mail"
+            android:textSize="@dimen/main_title_size" />
+    </RelativeLayout>
+
+</ScrollView>

+ 9 - 0
res/menu/main.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 8 - 0
res/values-sw600dp/dimens.xml

@@ -0,0 +1,8 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw600dp devices (e.g. 7" tablets) here.
+    -->
+
+</resources>

+ 9 - 0
res/values-sw720dp-land/dimens.xml

@@ -0,0 +1,9 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+    -->
+    <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>

+ 11 - 0
res/values-v11/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!--
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+        <!-- API 11 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
res/values-v14/styles.xml

@@ -0,0 +1,12 @@
+<resources>
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 10 - 0
res/values/dimens.xml

@@ -0,0 +1,10 @@
+<resources>
+
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+	
+    <dimen name="main_title_size">18sp</dimen>
+    <dimen name="second_title_size">16sp</dimen>
+    <dimen name="desc_title_size">12sp</dimen>
+</resources>

+ 31 - 0
res/values/strings.xml

@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">定位sdk Demo</string>
+    <string name="hello_world">Hello world!</string>
+    <string name="action_settings">Settings</string>
+    <string name="startlocation">开启定位</string>
+    <string name="stoplocation">停止定位</string>
+    <string name="error_code_desc">错误码说明</string>
+    <string name="qa_title">常见问题</string>
+    <string name="hight_accuracy_desc">高精度定位模式下,会同时使用GPS、Wifi和基站定位,返回的是当前条件下精度最好的定位结果</string>
+    <string name="saving_battery_desc">低功耗定位模式下,仅使用网络定位即Wifi和基站定位,返回的是当前条件下精度最好的网络定位结果</string>
+    <string name="device_sensor_desc">仅用设备定位模式下,只使用用户的GPS进行定位。这个模式下,由于GPS芯片锁定需要时间,首次定位速度会需要一定的时间</string>
+    <string name="error_code_detail"> 61 : GPS定位结果\n
+		62 : 扫描整合定位依据失败。此时定位结果无效。\n
+		63 : 网络异常,没有成功向服务器发起请求。此时定位结果无效。\n
+		65 : 定位缓存的结果。\n
+		66 : 离线定位结果。通过requestOfflineLocaiton调用时对应的返回结果\n
+		67 : 离线定位失败。通过requestOfflineLocaiton调用时对应的返回结果\n
+		68 : 网络连接失败时,查找本地离线定位时对应的返回结果\n
+		161: 表示网络定位结果\n
+		162~167: 服务端定位失败\n
+		502:key参数错误\n
+		505:key不存在或者非法\n
+		601:key服务被开发者自己禁用\n
+		602:key mcode不匹配\n
+		501~700:key验证失败\n</string>
+    <string name="qa_callback">问题反馈方法</string>
+    <string name="qa_callback_mail">mapapi@baidu.com</string>
+
+</resources>

+ 20 - 0
res/values/styles.xml

@@ -0,0 +1,20 @@
+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="AppBaseTheme">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+    </style>
+
+</resources>

+ 135 - 0
src/com/baidu/baidulocationdemo/LocationActivity.java

@@ -0,0 +1,135 @@
+package com.baidu.baidulocationdemo;
+
+import com.baidu.location.LocationClient;
+import com.baidu.location.LocationClientOption;
+import com.baidu.location.LocationClientOption.LocationMode;
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.method.ScrollingMovementMethod;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.RadioGroup;
+import android.widget.RadioGroup.OnCheckedChangeListener;
+import android.widget.TextView;
+
+public class LocationActivity extends Activity{
+    private LocationClient mLocationClient;
+    private TextView LocationResult,ModeInfor;
+    private Button startLocation;
+    private RadioGroup selectMode,selectCoordinates;
+    private EditText frequence;
+    private LocationMode tempMode = LocationMode.Hight_Accuracy;
+    private String tempcoor="gcj02";
+    private CheckBox checkGeoLocation;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        // TODO Auto-generated method stub
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.location);
+        mLocationClient = ((LocationApplication)getApplication()).mLocationClient;
+
+        LocationResult = (TextView)findViewById(R.id.textView1);
+        LocationResult.setMovementMethod(ScrollingMovementMethod.getInstance());
+        ModeInfor= (TextView)findViewById(R.id.modeinfor);
+        ModeInfor.setText(getString(R.string.hight_accuracy_desc));
+        ((LocationApplication)getApplication()).mLocationResult = LocationResult;
+        frequence = (EditText)findViewById(R.id.frequence);
+        checkGeoLocation = (CheckBox)findViewById(R.id.geolocation);
+        startLocation = (Button)findViewById(R.id.addfence);
+        startLocation.setOnClickListener(new OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                // TODO Auto-generated method stub
+                initLocation();
+
+                if(startLocation.getText().equals(getString(R.string.startlocation))){
+                    mLocationClient.start();//定位SDK start之后会默认发起一次定位请求,开发者无须判断isstart并主动调用request
+                    startLocation.setText(getString(R.string.stoplocation));
+                }else{
+                    mLocationClient.stop();
+                    startLocation.setText(getString(R.string.startlocation));
+                }
+
+
+            }
+        });
+        selectMode = (RadioGroup)findViewById(R.id.selectMode);
+        selectCoordinates= (RadioGroup)findViewById(R.id.selectCoordinates);
+        selectMode.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                // TODO Auto-generated method stub
+                String ModeInformation = null;
+                switch (checkedId) {
+                    case R.id.radio_hight:
+                        tempMode = LocationMode.Hight_Accuracy;
+                        ModeInformation = getString(R.string.hight_accuracy_desc);
+                        break;
+                    case R.id.radio_low:
+                        tempMode = LocationMode.Battery_Saving;
+                        ModeInformation = getString(R.string.saving_battery_desc);
+                        break;
+                    case R.id.radio_device:
+                        tempMode = LocationMode.Device_Sensors;
+                        ModeInformation = getString(R.string.device_sensor_desc);
+                        break;
+                    default:
+                        break;
+                }
+                ModeInfor.setText(ModeInformation);
+            }
+        });
+        selectCoordinates.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+
+            @Override
+            public void onCheckedChanged(RadioGroup group, int checkedId) {
+                // TODO Auto-generated method stub
+                switch (checkedId) {
+                    case R.id.radio_gcj02:
+                        tempcoor="gcj02";//国家测绘局标准
+                        break;
+                    case R.id.radio_bd09ll:
+                        tempcoor="bd09ll";//百度经纬度标准
+                        break;
+                    case R.id.radio_bd09:
+                        tempcoor="bd09";//百度墨卡托标准
+                        break;
+                    default:
+                        break;
+                }
+            }
+        });
+    }
+    @Override
+    protected void onStop() {
+        // TODO Auto-generated method stub
+        mLocationClient.stop();
+        super.onStop();
+    }
+
+    private void initLocation(){
+        LocationClientOption option = new LocationClientOption();
+        option.setLocationMode(tempMode);//可选,默认高精度,设置定位模式,高精度,低功耗,仅设备
+        option.setCoorType(tempcoor);//可选,默认gcj02,设置返回的定位结果坐标系,
+        int span=1000;
+        try {
+            span = Integer.valueOf(frequence.getText().toString());
+        } catch (Exception e) {
+            // TODO: handle exception
+        }
+        option.setScanSpan(span);//可选,默认0,即仅定位一次,设置发起定位请求的间隔需要大于等于1000ms才是有效的
+        option.setIsNeedAddress(checkGeoLocation.isChecked());//可选,设置是否需要地址信息,默认不需要
+        option.setOpenGps(true);//可选,默认false,设置是否使用gps
+        option.setLocationNotify(true);//可选,默认false,设置是否当gps有效时按照1S1次频率输出GPS结果
+        option.setIgnoreKillProcess(true);//可选,默认true,定位SDK内部是一个SERVICE,并放到了独立进程,设置是否在stop的时候杀死这个进程,默认不杀死
+        option.setEnableSimulateGps(false);//可选,默认false,设置是否需要过滤gps仿真结果,默认需要
+        option.setIsNeedLocationDescribe(true);//可选,默认false,设置是否需要位置语义化结果,可以在BDLocation.getLocationDescribe里得到,结果类似于“在北京天安门附近”
+        option.setIsNeedLocationPoiList(true);//可选,默认false,设置是否需要POI结果,可以在BDLocation.getPoiList里得到
+        mLocationClient.setLocOption(option);
+    }
+}

+ 122 - 0
src/com/baidu/baidulocationdemo/LocationApplication.java

@@ -0,0 +1,122 @@
+package com.baidu.baidulocationdemo;
+
+import com.baidu.location.BDLocation;
+import com.baidu.location.BDLocationListener;
+import com.baidu.location.LocationClient;
+import com.baidu.location.Poi;
+import android.app.Application;
+import android.app.Service;
+import android.os.Vibrator;
+import android.util.Log;
+import android.widget.TextView;
+import java.util.List;
+
+/**
+ * 主Application,所有百度定位SDK的接口说明请参考线上文档:http://developer.baidu.com/map/loc_refer/index.html
+ *
+ * 百度定位SDK官方网站:http://developer.baidu.com/map/index.php?title=android-locsdk
+ */
+public class LocationApplication extends Application {
+    public LocationClient mLocationClient;
+    public MyLocationListener mMyLocationListener;
+
+    public TextView mLocationResult,logMsg;
+    public TextView trigger,exit;
+    public Vibrator mVibrator;
+
+    @Override
+    public void onCreate() {
+        super.onCreate();
+        mLocationClient = new LocationClient(this.getApplicationContext());
+        mMyLocationListener = new MyLocationListener();
+        mLocationClient.registerLocationListener(mMyLocationListener);
+        mVibrator =(Vibrator)getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE);
+    }
+
+
+    /**
+     * 实现实时位置回调监听
+     */
+    public class MyLocationListener implements BDLocationListener {
+
+        @Override
+        public void onReceiveLocation(BDLocation location) {
+            //Receive Location
+            StringBuffer sb = new StringBuffer(256);
+            sb.append("time : ");
+            sb.append(location.getTime());
+            sb.append("\nerror code : ");
+            sb.append(location.getLocType());
+            sb.append("\nlatitude : ");
+            sb.append(location.getLatitude());
+            sb.append("\nlontitude : ");
+            sb.append(location.getLongitude());
+            sb.append("\nradius : ");
+            sb.append(location.getRadius());
+            if (location.getLocType() == BDLocation.TypeGpsLocation){// GPS定位结果
+                sb.append("\nspeed : ");
+                sb.append(location.getSpeed());// 单位:公里每小时
+                sb.append("\nsatellite : ");
+                sb.append(location.getSatelliteNumber());
+                sb.append("\nheight : ");
+                sb.append(location.getAltitude());// 单位:米
+                sb.append("\ndirection : ");
+                sb.append(location.getDirection());
+                sb.append("\naddr : ");
+                sb.append(location.getAddrStr());
+                sb.append("\ndescribe : ");
+                sb.append("gps定位成功");
+
+            } else if (location.getLocType() == BDLocation.TypeNetWorkLocation){// 网络定位结果
+                sb.append("\naddr : ");
+                sb.append(location.getAddrStr());
+                //运营商信息
+                sb.append("\noperationers : ");
+                sb.append(location.getOperators());
+                sb.append("\ndescribe : ");
+                sb.append("网络定位成功");
+            } else if (location.getLocType() == BDLocation.TypeOffLineLocation) {// 离线定位结果
+                sb.append("\ndescribe : ");
+                sb.append("离线定位成功,离线定位结果也是有效的");
+            } else if (location.getLocType() == BDLocation.TypeServerError) {
+                sb.append("\ndescribe : ");
+                sb.append("服务端网络定位失败,可以反馈IMEI号和大体定位时间到loc-bugs@baidu.com,会有人追查原因");
+            } else if (location.getLocType() == BDLocation.TypeNetWorkException) {
+                sb.append("\ndescribe : ");
+                sb.append("网络不同导致定位失败,请检查网络是否通畅");
+            } else if (location.getLocType() == BDLocation.TypeCriteriaException) {
+                sb.append("\ndescribe : ");
+                sb.append("无法获取有效定位依据导致定位失败,一般是由于手机的原因,处于飞行模式下一般会造成这种结果,可以试着重启手机");
+            }
+            sb.append("\nlocationdescribe : ");// 位置语义化信息
+            sb.append(location.getLocationDescribe());
+            List<Poi> list = location.getPoiList();// POI信息
+            if (list != null) {
+                sb.append("\npoilist size = : ");
+                sb.append(list.size());
+                for (Poi p : list) {
+                    sb.append("\npoi= : ");
+                    sb.append(p.getId() + " " + p.getName() + " " + p.getRank());
+                }
+            }
+            logMsg(sb.toString());
+            Log.i("BaiduLocationApiDem", sb.toString());
+        }
+
+
+    }
+
+
+    /**
+     * 显示请求字符串
+     * @param str
+     */
+    public void logMsg(String str) {
+        try {
+            if (mLocationResult != null)
+                mLocationResult.setText(str);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+}

+ 66 - 0
src/com/baidu/baidulocationdemo/MainActivity.java

@@ -0,0 +1,66 @@
+package com.baidu.baidulocationdemo;
+
+import java.util.ArrayList;
+import java.util.List;
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+
+public class MainActivity extends Activity {
+
+	private ListView FunctionList ;
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.function_list);
+		FunctionList = (ListView)findViewById(R.id.functionList);
+		FunctionList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1,getData()));
+	}
+	   
+    @Override
+	protected void onStart() {
+		// TODO Auto-generated method stub
+		super.onStart();
+		FunctionList.setOnItemClickListener(new OnItemClickListener() {
+
+			@Override
+			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
+					long arg3) {
+				// TODO Auto-generated method stub
+				Class TargetClass = null; 
+				switch (arg2) {
+				case 0:
+					TargetClass = LocationActivity.class;
+					break;
+				case 1:
+					TargetClass = NotifyActivity.class;
+					break;
+				case 2 :
+					TargetClass = QuestActivity.class;
+					break;
+				default:
+					break;
+				}
+				if(TargetClass != null){
+					Intent intent = new Intent(MainActivity.this, TargetClass);
+					startActivity(intent);
+				}
+			}
+		});
+	}
+
+	private List<String> getData(){
+         
+        List<String> data = new ArrayList<String>();
+        data.add("基础定位功能");
+        data.add("位置消息提醒");
+        data.add("常见问题说明");
+         
+        return data;
+    }
+}

+ 98 - 0
src/com/baidu/baidulocationdemo/NotifyActivity.java

@@ -0,0 +1,98 @@
+package com.baidu.baidulocationdemo;
+
+
+import com.baidu.location.BDLocation;
+import com.baidu.location.BDLocationListener;
+import com.baidu.location.BDNotifyListener;
+import com.baidu.location.LocationClient;
+import android.app.Activity;
+import android.app.Service;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.Vibrator;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.Toast;
+
+public class NotifyActivity extends Activity{
+
+    private Button startNotify;
+    private Vibrator mVibrator;
+    private LocationClient mLocationClient;
+    private NotiftLocationListener listener;
+    private double longtitude,latitude;
+    private NotifyLister mNotifyLister;
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        // TODO Auto-generated method stub
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.notify);
+        listener = new NotiftLocationListener();
+        mVibrator =(Vibrator)getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE);
+
+        startNotify = (Button)findViewById(R.id.notifystart);
+        mLocationClient  = new LocationClient(this);
+        mLocationClient.registerLocationListener(listener);
+        startNotify.setOnClickListener(new OnClickListener() {
+
+            @Override
+            public void onClick(View v) {
+                // TODO Auto-generated method stub
+                if(startNotify.getText().toString().equals("开启位置提醒")){
+                    mLocationClient.start();
+                    startNotify.setText("关闭位置提醒");
+                }else{
+                    if(mNotifyLister!=null){
+                        mLocationClient.removeNotifyEvent(mNotifyLister);
+                        startNotify.setText("开启位置提醒");
+                    }
+
+                }
+
+
+            }
+        });
+    }
+
+    @Override
+    protected void onStop() {
+        // TODO Auto-generated method stub
+        super.onStop();
+        mLocationClient.removeNotifyEvent(mNotifyLister);
+        mLocationClient = null;
+        mNotifyLister= null;
+        listener = null;
+
+    }
+
+    private Handler notifyHandler = new Handler(){
+
+        @Override
+        public void handleMessage(Message msg) {
+            // TODO Auto-generated method stub
+            super.handleMessage(msg);
+            mNotifyLister = new NotifyLister();
+            mNotifyLister.SetNotifyLocation(latitude,longtitude, 3000,"gcj02");//4个参数代表要位置提醒的点的坐标,具体含义依次为:纬度,经度,距离范围,坐标系类型(gcj02,gps,bd09,bd09ll)
+            mLocationClient.registerNotify(mNotifyLister);
+        }
+
+    };
+    public class NotiftLocationListener implements BDLocationListener {
+
+        @Override
+        public void onReceiveLocation(BDLocation location) {
+            //Receive Location
+            longtitude = location.getLongitude();
+            latitude = location.getLatitude();
+            notifyHandler.sendEmptyMessage(0);
+        }
+    }
+    public class NotifyLister extends BDNotifyListener{
+        public void onNotify(BDLocation mlocation, float distance){
+            mVibrator.vibrate(1000);//振动提醒已到设定位置附近
+            Toast.makeText(NotifyActivity.this, "震动提醒", Toast.LENGTH_SHORT).show();
+        }
+    }
+}

+ 16 - 0
src/com/baidu/baidulocationdemo/QuestActivity.java

@@ -0,0 +1,16 @@
+package com.baidu.baidulocationdemo;
+
+
+import android.app.Activity;
+import android.os.Bundle;
+
+/**
+ * 常见问题
+ */
+public class QuestActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.quest_activity);
+    }
+}