Project Configuration & Description
Add usage rights to AndroidManifest.xml
To ensure the normal operation of the program, you need to add the corresponding usage rights in the configuration file AndroidManifest.xml, such as network location service, mobile connection status, storage status, etc. The code is as follows:
- <!-- Allow programs to open network sockets -->
- <uses-permission android:name="android.permission.INTERNET" />
- <!-- Allow programs to access network status -->
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <!-- Allow users to change the network connection status -->
- <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
- <!-- Allow users to access WiFi network information status -->
- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
- <!-- Allow users to change the WiFi connection status -->
- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
- <!-- Program access rough location -->
- <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
- <!-- Allow users to access precise locations -->
- <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
- <!-- Allow program to read phone status -->
- <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
- <!-- Allow programs to write to external storage devices -->
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Add Android version support in AndroidManifest
Based on SDK development, Android2.3 and above are required. You need to make the following settings in AndroidManifest.xml, for example
- <user-sdk android:minSdkVersion="9"/>
Add SDK related JAR package and SO
1. Add a JAR package
Click File in the menu and select File>Project Structure... to bring up the Project Structure dialog box.
In the Project Structure dialog, do the following:
(1) Check the "app" tab.
(2) Select the Dependencies tab under the app.
(3) Click the green “+” button on the right to select the jar. Select the required jar package, corresponding to the jar package in the jar folder of the SDK product.
(4) After the addition is successful, the corresponding jar file will appear in the Libraries list.
(5) Click "OK" to complete the addition of the JARs file.
2. Add a SO file
Use AK
Using AK requires adding the jar and so related to the authorization to the project
In the Project Structure dialog, do the following:
1. Add AK configuration to AndroidManifest
AK is configured in AndroidManifestKey. The code example is as follows:
- <application
- android:icon="@drawable/icon"
- android:label="@string/app_name" >
- <meta-data
- android:name="Navinfo_AK"
- Android:value="Please enter your user AK"/>
- ……
- <application>
2. Initialize the base library in the application
You can customize the Application when the application is initialized, initialize the authorization and pass in the AK. The sample code is as follows:
- public class SDKApplication extends Application {
- @Override
- public void onCreate() {
- super.onCreate();
- NavinfoApi.init(this);
- }
- }