Home > Mobile >  Baidu navigation cannot be initialized
Baidu navigation cannot be initialized

Time:10-09

Map the development of the great god, is there anyone Android baidu baidu navigation can't initialize, always return to my first interface, I also guide in the jar package, also have other so files, but why can't initialize??????????


Private Boolean hasBasePhoneAuth () {
PackageManager PM=this. GetPackageManager ();
For (String auth: authBaseArr) {
If (PM. CheckPermission (auth, enclosing getPackageName ())!=PackageManager
PERMISSION_GRANTED) {
return false;
}
}
return true;
}

Private void initNavi () {
//application permissions
If (android. OS. Build. VERSION. SDK_INT & gt; 23)={
if (! HasBasePhoneAuth ()) {
Enclosing requestPermissions (authBaseArr authBaseRequestCode);
//return;
Toast. MakeText (RoutActivity. This! "" HasBasePhoneAuth (), "Toast. LENGTH_SHORT). The show ();
}
}
If (BaiduNaviManagerFactory. GetBaiduNaviManager (.) isInited ()) {
HasInitSuccess=true;
//return;
Toast. MakeText (RoutActivity. This hasInitSuccess="true", Toast. LENGTH_SHORT), show ();
}

BaiduNaviManager. GetInstance (). The init (RoutActivity. This,
MSDPath APP_FOLDER_NAME,
New IBaiduNaviManager. INaviInitListener () {
@ Override
Public void onAuthResult (int, String s) {
If (0==I) {
Authinfo="key check success";
Toast. MakeText (RoutActivity. This engine initialization, Toast. LENGTH_SHORT), show ();
} else {
Authinfo="key check failure" + s.
}
RoutActivity. This. RunOnUiThread (new Runnable () {
@ Override
Public void the run () {
Toast. MakeText (RoutActivity. This, authinfo, Toast. LENGTH_SHORT), show ();
}
});
}

@ Override
Public void initStart () {
Toast. MakeText (RoutActivity. This, "baidu engine initialization began," Toast. LENGTH_SHORT), show ();
}

@ Override
Public void initSuccess () {
Toast. MakeText (RoutActivity. This, "baidu engine initialization success", Toast. LENGTH_SHORT), show ();
}

@ Override
Public void initFailed (int I) {
Toast. MakeText (RoutActivity. This, "baidu engine initialization failed," Toast. LENGTH_SHORT), show ();
}
});
}
@ Override
Public void onRequestPermissionsResult (int requestCode, String [] permissions, int []
GrantResults) {
Super. OnRequestPermissionsResult (requestCode, permissions, grantResults);
If (requestCode==authBaseRequestCode) {
For (int ret: grantResults) {
If (ret==0) {
continue;
} else {
Toast. MakeText (RoutActivity. This. GetApplicationContext (),
"The lack of navigation basic permissions!" , Toast.LENGTH_SHORT).show();
return;
}
}
InitNavi ();
}
}

CodePudding user response:

Check your manifest file
See if there are any permission to add
<meta - data
The android: name="com. Baidu. Lbsapi. API_KEY"
You android: value="https://bbs.csdn.net/topics/"/& gt;

The android: name="com. Baidu. Location. F"
Android: enabled="true"
Android: process=": the remote"/& gt;


Package com. Example. Ar. Bleapp;


The import android. App. Application;
The import android. App. Service;
. The import of the android OS. The Vibrator;

The import com. Baidu. Mapapi. CoordType;
The import com. Baidu. Mapapi. SDKInitializer;
The import com. Example. Ar. Bleapp. Service. The LocationService;

/* *
* Created by n004970 on 2019/2/25.
*/

Public class BleGpsApplication extends Application {

Public LocationService LocationService;
Public Vibrator mVibrator;
@ Override
Public void onCreate () {
super.onCreate();

LocationService=new locationService (getApplicationContext ());
MVibrator=(Vibrator) getApplicationContext (.) getSystemService (Service. VIBRATOR_SERVICE);
//initialize the context information before using SDK components, incoming ApplicationContext
SDKInitializer. The initialize (this);
//since 4.3.0, all interface SDK support baidu baidu map coordinates, and the bureau coordinates measurement, set up by this method you are using the coordinates of the type.
//including BD09LL and GCJ02 two coordinates, the default is BD09LL coordinates,
SDKInitializer. SetCoordType (CoordType. BD09LL);
}
}


Package com. Example. Ar. Bleapp;

The import android. Content. Intent;
The import android. Graphics. Point;
import android.os.Bundle;
The import android. Support. The annotation. NonNull;
The import android. Support. The design. The widget. BottomNavigationView;
The import android. Support. V7. App. AppCompatActivity;
import android.util.Log;
The import android. View. MenuItem;
The import android. View. MotionEvent;
The import android. View. The view;
The import android. Widget. TextView;

The import com. Baidu. Location. BDAbstractLocationListener;
The import com. Baidu. Location. BDLocation;
The import com. Baidu. Location. LocationClient;
The import com. Baidu. Location. LocationClientOption;
The import com. Baidu. Mapapi. Map. BaiduMap;
The import com. Baidu. Mapapi. Map. BitmapDescriptor;
The import com. Baidu. Mapapi. Map. BitmapDescriptorFactory;
The import com. Baidu. Mapapi. Map. MapStatus;
The import com. Baidu. Mapapi. Map. MapStatusUpdateFactory;
The import com. Baidu. Mapapi. Map. MapView;
The import com. Baidu. Mapapi. Map. MarkerOptions;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related