When you use Baidu api to obtain the current longitude and latitude, you can use the api demo with the same code, but the error BMapManager cannot be instantiated.
This is written in the demo:
Package com. stgmobile. cyt. activity. enterprise;
Import android. app. Application;
Import android. util. Log;
Import android. widget. Toast;
Import com. baidu. mapapi. BMapManager;
Import com. baidu. mapapi. MKEvent;
Import com. baidu. mapapi. MKGeneralListener;
Public class BMapApp extends Application {
Static BMapApp mDemoApp;
// Baidu MapAPI management class
BMapManager mBMapMan = null;
// Authorization Key
// Address: http://developer.baidu.com/map/android-mobile-apply-key.htm
String mStrKey = "E411350F624D8D13522D964224B5B960950BE7B2 ";
Boolean m_bKeyRight = true; // The Authorization Key is correct and passes verification.
// Common event listening, used to handle common network errors, authorization verification errors, etc.
Static class MyGeneralListener implements MKGeneralListener {
Public void onGetNetworkState (int iError ){
Log. d ("MyGeneralListener", "onGetNetworkState error is" + iError );
Toast. makeText (BMapApp. mDemoApp. getApplicationContext (), "your network has an error! ",
Toast. LENGTH_LONG). show ();
}
@ Override
Public void onGetPermissionState (int iError ){
Log. d ("MyGeneralListener", "onGetPermissionState error is" + iError );
If (iError = MKEvent. ERROR_PERMISSION_DENIED ){
// Authorization Key error:
Toast. makeText (BMapApp. mDemoApp. getApplicationContext (),
"Enter the correct authorization Key in the BMapApiDemoApp. java file! ",
Toast. LENGTH_LONG). show ();
BMapApp. mDemoApp. m_bKeyRight = false;
}
}
}
@ Override
Public void onCreate (){
Log. v ("BMapApp", "onCreate ");
MDemoApp = this;
MBMapMan = new BMapManager (this );
Boolean isSuccess = mBMapMan. init (this. mStrKey, new MyGeneralListener ());
// The map sdk is initialized successfully and the location listening time is set.
If (isSuccess ){
MBMapMan. getLocationManager (). setpolicyinternal (10, 5 );
}
Else {
// Map sdk initialization failed. You cannot use the sdk
}
Super. onCreate ();
}
@ Override
// Call the destroy () function of mapadpi before your app exits to avoid time consumption caused by repeated initialization.
Public void onTerminate (){
// TODO Auto-generated method stub
If (mBMapMan! = Null ){
MBMapMan. destroy ();
MBMapMan = null;
}
Super. onTerminate ();
}
}
The focus is on the red sentence. In this case, I cannot find this object. I thought there was a problem with the package. How many times have the so file been imported? The so file has also been exported...
Write mBMapMan = new BMapManager (getApplicationContext ());