博客專(zhuān)欄

EEPW首頁(yè) > 博客 > 基于Mobile SDK V4版固件開(kāi)發(fā)大疆無(wú)人機(jī)手機(jī)端遙控器(3)

基于Mobile SDK V4版固件開(kāi)發(fā)大疆無(wú)人機(jī)手機(jī)端遙控器(3)

發(fā)布人:美男子玩編程 時(shí)間:2023-06-21 來(lái)源:工程師 發(fā)布文章

第三篇文章準(zhǔn)備單獨(dú)拿出來(lái)寫(xiě),因?yàn)樵诖蠼疄槿藱C(jī)的所有功能中,航線規(guī)劃的功能最為復(fù)雜,也相當(dāng)?shù)姆爆崳@里需要說(shuō)仔細(xì)一點(diǎn),可能會(huì)將代碼進(jìn)行多步分解。

1

航線規(guī)劃

航線打點(diǎn) 

在地圖中手動(dòng)選擇點(diǎn)位選擇完成航線打點(diǎn);若打點(diǎn)位置錯(cuò)了可進(jìn)行點(diǎn)位刪除。


圖片


航點(diǎn)設(shè)置 

可對(duì)航線點(diǎn)位進(jìn)行設(shè)置,如飛行高度,速度(慢速:3m/s;中速: 7m/s;高速:10 m/s)、任務(wù)結(jié)束后操作及航向,點(diǎn)擊[設(shè)置]按鈕完成設(shè)置。

設(shè)置完成后會(huì)顯示總距離及飛行總時(shí)間。

航線上傳

點(diǎn)擊[上傳]按鈕,進(jìn)行航線上傳。可以進(jìn)入本地存儲(chǔ)中選擇航線文件進(jìn)行上傳,航線文件為 .kml結(jié)尾。


圖片


航線執(zhí)行 

點(diǎn)擊 [開(kāi)始]按鈕,則可對(duì)航線進(jìn)行執(zhí)行。若中途需要暫停也可點(diǎn)擊[暫停]安裝進(jìn)行暫停操作。

航線管理

按鈕即可進(jìn)入航線管理界面。

圖片


獲取航線 

點(diǎn)擊[獲取]按鈕,即可將航線信息展示到地圖界面中。

圖片


2

主要功能代碼

創(chuàng)建activity_setting_route.xml及SettingRouteActivity文件。

activity_setting_route.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".ui.SettingRouteActivity">

    <include
        android:id="@+id/layout_route"
        layout="@layout/activity_toolbar">
</include>
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <com.amap.api.maps.MapView
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_centerInParent="true"
            android:layout_marginTop="5dp">

            <Button
                android:id="@+id/btn_delete"
                android:layout_width="60dp"
                android:layout_height="30dp"
                android:visibility="gone"
                android:text="刪除"
                android:textColor="@color/white"
                android:background="@drawable/button_task_background">
</Button>
            <Button
                android:id="@+id/btn_finish"
                android:layout_width="60dp"
                android:layout_height="30dp"
                android:visibility="gone"
                android:textColor="@color/white"
                android:background="@drawable/button_task_background"
                android:text="完成">
</Button>
            <Button
                android:id="@+id/btn_setting"
                android:layout_width="60dp"
                android:layout_height="30dp"
                android:visibility="gone"
                android:textColor="@color/white"
                android:background="@drawable/button_task_background"
                android:text="設(shè)置">
</Button>
            <Button
                android:id="@+id/btn_upload"
                android:layout_width="60dp"
                android:layout_height="30dp"
                android:visibility="gone"
                android:textColor="@color/white"
                android:background="@drawable/button_task_background"
                android:text="上傳">
</Button>
            <Button
                android:id="@+id/btn_start"
                android:layout_width="60dp"
                android:layout_height="30dp"
                android:visibility="gone"
                android:textColor="@color/white"
                android:background="@drawable/button_task_background"
                android:text="開(kāi)始">
</Button>
            <Button
                android:id="@+id/btn_stop"
                android:layout_width="60dp"
                android:layout_height="30dp"
                android:visibility="gone"
                android:textColor="@color/white"
                android:background="@drawable/button_task_background"
                android:text="暫停">
</Button>
        </LinearLayout>
        <LinearLayout
            android:id="@+id/ll_information"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerInParent="true"
            android:layout_marginBottom="5dp"
            android:padding="10dp"
            android:visibility="gone"
            android:background="@color/color_nav_Item_unselected">

            <TextView
                android:id="@+id/tv_height"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="高度:"
                android:textColor="@color/white"
                >
</TextView>
            <TextView
                android:id="@+id/tv_speed"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="速度:"
                android:textColor="@color/white"
                android:layout_marginLeft="10dp"
                >
</TextView>
            <TextView
                android:id="@+id/tv_count"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="航點(diǎn)數(shù):"
                android:textColor="@color/white"
                android:layout_marginLeft="10dp"
                >
</TextView>
            <TextView
                android:id="@+id/tv_distance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="總距離:"
                android:textColor="@color/white"
                android:layout_marginLeft="10dp"
                >
</TextView>
            <TextView
                android:id="@+id/tv_time"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="總時(shí)間:"
                android:textColor="@color/white"
                android:layout_marginLeft="10dp"
                >
</TextView>
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>

SettingRouteActivity

public class SettingRouteActivity extends BaseActivity implements AMap.OnMarkerClickListenerView.OnClickListenerAMap.OnMapClickListenerLocationSourceAMapLocationListenerAMap.InfoWindowAdapter {
    @BindView(R.id.layout_route)
        View mViewLayoutToolbar;
        @BindView(R.id.ll_route)
        LinearLayout mLinearLayout;
        @BindView(R.id.tv_toolbar_title)
        TextView mTextViewToolbarTitle;
    //    @BindView(R.id.map)
    //    MapView mMapView;
        @BindView(R.id.btn_delete)
        Button mButtonDelete;
        @BindView(R.id.btn_finish)
        Button mButtonFinish;
        @BindView(R.id.btn_setting)
        Button mButtonSetting;
        @BindView(R.id.btn_upload)
        Button mButtonUpload;
        @BindView(R.id.btn_start)
        Button mButtonStart;
        @BindView(R.id.btn_stop)
        Button mButtonStop;
        @BindView(R.id.ll_information)
        LinearLayout mLinearLayoutInformation;
        @BindView(R.id.tv_height)
        TextView mTextViewHeight;
        @BindView(R.id.tv_speed)
        TextView mTextViewSpeed;
        @BindView(R.id.tv_count)
        TextView mTextViewCount;
        @BindView(R.id.tv_distance)
        TextView mTextViewDistance;
        @BindView(R.id.tv_time)
        TextView mTextViewTime;
        private MapView mMapView;
        private OnLocationChangedListener mListener;
        private AMapLocationClient mlocationClient;
        private AMapLocationClientOption mLocationOption;
        private double D_latitude, D_longitude;
        private UiSettings mUiSettings;
        private AMap aMap;
        private Marker droneMarker = null;
        private float altitude = 100.0f;
        private float mSpeed = 10.0f;
        private boolean isAdd = false;
        private final Map<Integer, Marker> mMarkers = new ConcurrentHashMap<Integer, Marker>();
        private Marker mClickMarker;
        private List<Waypoint> waypointList = new ArrayList<>();
        private List<LatLng> mLatLng = new ArrayList<>();
        private List<PointInfo> mPointInfo = new ArrayList<>();
        public static WaypointMission.Builder waypointMissionBuilder;
        private FlightController mFlightController;
        private WaypointMissionOperator instance;
        private WaypointMissionFinishedAction mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;
        private WaypointMissionHeadingMode mHeadingMode = WaypointMissionHeadingMode.AUTO;
        private SQLiteHelper mSQLiteHelper;
        private String FinishedAction, HeadingMode;
        //自定義窗體
        View infoWindow = null;
        int speed_RG_id = 0;
        int actionAfterFinished_RG_id = 0;
        int heading_RG_id = 0;
        //kim
        static ReadKml readKml = new ReadKml();
        private static List<Coordinate> sampleList = readKml.getCoordinateList();
        @Override
        public void initViews() {
            mLinearLayout.setVisibility(View.VISIBLE);
            mTextViewToolbarTitle.setText("航線規(guī)劃");
            IntentFilter filter = new IntentFilter();
            filter.addAction(ReceiverApplication.FLAG_CONNECTION_CHANGE);
            registerReceiver(mReceiver, filter);
            mMapView = findViewById(R.id.map);
            mMapView.onCreate(InstanceState);
            initMapView();
            addListener();
            onProductConnectionChange();
        }
        @Override
        protected void onResume() {
            super.onResume();
            initFlightController();
            mMapView.onResume();
        }
        /**
         * 方法必須重寫(xiě)
         */

        @Override
        protected void onSaveInstanceState(Bundle outState) {
            super.onSaveInstanceState(outState);
            mMapView.onSaveInstanceState(outState);
        }
        @Override
        protected void onPause() {
            super.onPause();
            mMapView.onPause();
            deactivate();
        }
        @Override
        protected void onDestroy() {
            super.onDestroy();
            unregisterReceiver(mReceiver);
            removeListener();
            mMapView.onDestroy();
            if (null != mlocationClient) {
                mlocationClient.onDestroy();
            }
        }
        @Override
        public void initDatas() {
        }
        @Override
        protected void requestData() {
        }
        private void initMapView() {
            if (aMap == null) {
                aMap = mMapView.getMap();
                mUiSettings = aMap.getUiSettings();
                mUiSettings.setMyLocationButtonEnabled(true);
                mUiSettings.setScaleControlsEnabled(true);
                aMap.setOnMapClickListener(this);// add the listener for click for amap object
                aMap.setLocationSource(this);
                aMap.setMyLocationEnabled(true);
                aMap.setInfoWindowAdapter(this);
                aMap.setOnMarkerClickListener(this);
                setupLocationStyle();
            }
        }
        private void setupLocationStyle() {
            // 自定義系統(tǒng)定位藍(lán)點(diǎn)
            MyLocationStyle myLocationStyle = new MyLocationStyle();
            // 自定義定位藍(lán)點(diǎn)圖標(biāo)
            myLocationStyle.myLocationIcon(BitmapDescriptorFactory.
                    fromResource(R.mipmap.icv_gps_point_36dp));
            // 自定義精度范圍的圓形邊框顏色
            myLocationStyle.strokeColor(Color.parseColor("#00000000"));
            //自定義精度范圍的圓形邊框?qū)挾?/span>
            myLocationStyle.strokeWidth(5);
            // 設(shè)置圓形的填充顏色
            myLocationStyle.radiusFillColor(Color.parseColor("#00000000"));
            // 將自定義的 myLocationStyle 對(duì)象添加到地圖上
            aMap.setMyLocationStyle(myLocationStyle);
        }
        @OnClick({R.id.img_kml_input, R.id.img_setting_route, R.id.img_start_fly, R.id.btn_delete,
                R.id.img_setting_clear, R.id.btn_finish, R.id.btn_setting, R.id.btn_upload,
                R.id.btn_start, R.id.btn_stop, R.id.img_back})
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.img_back:
                    SettingRouteActivity.this.finish();
                    break;
                case R.id.img_kml_input:
                    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                    intent.setType("*/*");//設(shè)置類(lèi)型,我這里是任意類(lèi)型,任意后綴的可以這樣寫(xiě)。
                    intent.addCategory(Intent.CATEGORY_OPENABLE);
                    startActivityForResult(intent, MyStatic.REQUEST_CODE_FILE);
                    break;
                case R.id.img_setting_route:
                    enableDisableAdd();
                    break;
                case R.id.img_setting_clear:
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            aMap.clear();
                            mMarkers.clear();
                            mPointInfo.clear();
                            mLinearLayoutInformation.setVisibility(View.GONE);
                            mButtonFinish.setVisibility(View.GONE);
                            mButtonSetting.setVisibility(View.GONE);
                            mButtonUpload.setVisibility(View.GONE);
                            mButtonStart.setVisibility(View.GONE);
                            mButtonStop.setVisibility(View.GONE);
                        }
                    });
                    waypointList.clear();
                    waypointMissionBuilder.waypointList(waypointList);
                    break;
                case R.id.img_start_fly:
                    atyAction(WaypointActivity.classMyStatic.REQUEST_CODE_ID);
                    break;
                case R.id.btn_delete:
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            aMap.clear();
                        }
                    });
                    for (int i = 0; i < mMarkers.size(); i++) {
                        if (mMarkers.get(i).getTitle().equals(mClickMarker.getTitle())) {
                            for (int j = i; j < mMarkers.size() - 1; j++) {
                                mMarkers.put(j, mMarkers.get(j + 1));
                            }
                            mMarkers.remove(mMarkers.size() - 1);
                        }
                    }
                    for (int i = 0; i < mMarkers.size(); i++) {
                        mMarkers.get(i).setTitle("航點(diǎn)" + (i + 1));
                    }
                    updateMarkWaypoint();
                    break;
                case R.id.btn_finish:
                    MyLog.d("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
                    MyLog.d("總距離:" + waypointMissionBuilder.calculateTotalDistance());
                    MyLog.d("總時(shí)間:" + waypointMissionBuilder.calculateTotalTime());
                    isAdd = false;
                    mButtonFinish.setVisibility(View.GONE);
                    mButtonSetting.setVisibility(View.VISIBLE);
                    mButtonUpload.setVisibility(View.VISIBLE);
                    showSettingDialog();
                    break;
                case R.id.btn_setting:
                    showSettingDialog();
                    break;
                case R.id.btn_upload:
                    uploadWayPointMission();
                    break;
                case R.id.btn_start:
                    startWaypointMission();
                    break;
                case R.id.btn_stop:
                    stopWaypointMission();
                    break;
            }
        }
        private void enableDisableAdd() {
            if (isAdd == false) {
                isAdd = true;
                mButtonFinish.setVisibility(View.VISIBLE);
            } else {
                isAdd = false;
            }
        }
        private void initFlightController() {
            BaseProduct product = ReceiverApplication.getProductInstance();
            if (product != null && product.isConnected()) {
                if (product instanceof Aircraft) {
                    mFlightController = ((Aircraft) product).getFlightController();
                }
            }
            if (mFlightController != null) {
                mFlightController.setStateCallback(
                        new FlightControllerState.Callback() {
                            @Override
                            public void onUpdate(FlightControllerState
                                                         djiFlightControllerCurrentState)
 
{
                                if (djiFlightControllerCurrentState.getAircraftLocation().getLatitude() != 0.0 && djiFlightControllerCurrentState.getAircraftLocation().getLongitude() != 0.0) {
                                    D_latitude = djiFlightControllerCurrentState.getAircraftLocation().getLatitude();
                                    D_longitude = djiFlightControllerCurrentState.getAircraftLocation().getLongitude();
                                }
                                updateDroneLocation();
                            }
                        });
            }
        }
        private void updateDroneLocation() {
            LatLng pos = new LatLng(D_latitude, D_longitude);
            //Create MarkerOptions object
            final MarkerOptions markerOptions = new MarkerOptions();
            markerOptions.position(pos);
            markerOptions.icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_aircraft_write_36dp));
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (droneMarker != null) {
                        droneMarker.remove();
                    }
                    if (checkGpsCoordination(D_latitude, D_longitude)) {
                        droneMarker = aMap.addMarker(markerOptions);
                    }
                }
            });
        }
        public static boolean checkGpsCoordination(double latitude, double longitude) {
            return (latitude > -90 && latitude < 90 && longitude > -180 && longitude < 180) && (latitude != 0f && longitude != 0f);
        }
        protected BroadcastReceiver mReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                onProductConnectionChange();
            }
        };
        private void onProductConnectionChange() {
            initFlightController();
        }
        private void addListener() {
            if (getWaypointMissionOperator() != null) {
                getWaypointMissionOperator().addListener(eventNotificationListener);
            }
        }
        private void removeListener() {
            if (getWaypointMissionOperator() != null) {
                getWaypointMissionOperator().removeListener(eventNotificationListener);
            }
        }
        private WaypointMissionOperatorListener eventNotificationListener = new WaypointMissionOperatorListener() {
            @Override
            public void onDownloadUpdate(WaypointMissionDownloadEvent downloadEvent) {
            }
            @Override
            public void onUploadUpdate(WaypointMissionUploadEvent uploadEvent) {
            }
            @Override
            public void onExecutionUpdate(WaypointMissionExecutionEvent executionEvent) {
            }
            @Override
            public void onExecutionStart() {
            }
            @Override
            public void onExecutionFinish(@Nullable final DJIError error) {
                showToasts("Execution finished: " + (error == null ? "Success!" : error.getDescription()));
            }
        };
        public WaypointMissionOperator getWaypointMissionOperator() {
            if (instance == null) {
                instance = DJISDKManager.getInstance().getMissionControl().getWaypointMissionOperator();
            }
            return instance;
        }
        @Override
        public void onMapClick(LatLng point) {
            if (isAdd == true) {
                markWaypoint(point);
                Waypoint mWaypoint = new Waypoint(point.latitude, point.longitude, altitude);
                //Add Waypoints to Waypoint arraylist;
                if (waypointMissionBuilder != null) {
                    waypointList.add(mWaypoint);
                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
                } else {
                    waypointMissionBuilder = new WaypointMission.Builder();
                    waypointList.add(mWaypoint);
                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
                }
                mTextViewCount.setText("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
                mTextViewDistance.setText("總距離:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
                mTextViewTime.setText("總時(shí)間:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
            } else {
                if (mClickMarker != null && mClickMarker.isInfoWindowShown()) {
                    mClickMarker.hideInfoWindow();
                    mButtonDelete.setVisibility(View.GONE);
                }
                //            showToasts("當(dāng)前未開(kāi)啟增加點(diǎn)模式");
            }
        }
        private void markWaypoint(LatLng point) {
            MarkerOptions markerOptions = new MarkerOptions();
            markerOptions.position(point);
            mPointInfo.add(new PointInfo(point.latitude, point.longitude));
            markerOptions.title("航點(diǎn)" + (mMarkers.size() + 1));
            markerOptions.snippet("事件:");
            markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
            markerOptions.infoWindowEnable(true);
            Marker marker = aMap.addMarker(markerOptions);
            mMarkers.put(mMarkers.size(), marker);
            marker.showInfoWindow();
            if (mMarkers.size() > 0) {
                mLatLng.clear();
                PolylineOptions PolylineOptions = new PolylineOptions();
                for (int i = 0; i < mMarkers.size(); i++) {
                    mLatLng.add(mMarkers.get(i).getPosition());
                }
                PolylineOptions.addAll(mLatLng);
                PolylineOptions.width(10);
                PolylineOptions.color(Color.argb(255111));
                aMap.addPolyline(PolylineOptions);
            }
        }
        private void updateMarkWaypoint() {
            mLatLng.clear();
            waypointList.clear();
            mPointInfo.clear();
            waypointMissionBuilder.waypointList(waypointList);
            for (int i = 0; i < mMarkers.size(); i++) {
                mPointInfo.add(new PointInfo(mMarkers.get(i).getPosition().latitude, mMarkers.get(i).getPosition().longitude));
                MarkerOptions markerOptions = new MarkerOptions();
                Waypoint mWaypoint = new Waypoint(mMarkers.get(i).getPosition().latitude, mMarkers.get(i).getPosition().longitude, altitude);
                waypointList.add(mWaypoint);
                markerOptions.position(mMarkers.get(i).getPosition());
                markerOptions.title(mMarkers.get(i).getTitle());
                markerOptions.snippet(mMarkers.get(i).getSnippet());
                markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
                aMap.addMarker(markerOptions);
                mLatLng.add(mMarkers.get(i).getPosition());
            }
            if (mMarkers.size() > 0) {
                PolylineOptions PolylineOptions = new PolylineOptions();
                PolylineOptions.addAll(mLatLng);
                PolylineOptions.width(10);
                PolylineOptions.color(Color.argb(255111));
                aMap.addPolyline(PolylineOptions);
            }
            waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
            mTextViewCount.setText("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
            mTextViewDistance.setText("總距離:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
            mTextViewTime.setText("總時(shí)間:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
            MyLog.d("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
            MyLog.d("總距離:" + waypointMissionBuilder.calculateTotalDistance());
            MyLog.d("總時(shí)間:" + waypointMissionBuilder.calculateTotalTime());
            mButtonDelete.setVisibility(View.GONE);
        }
        /**
         * 定位成功后回調(diào)函數(shù)
         */

        @Override
        public void onLocationChanged(AMapLocation amapLocation) {
            if (mListener != null && amapLocation != null) {
                if (amapLocation != null
                        && amapLocation.getErrorCode() == 0) {
                    D_latitude = amapLocation.getLatitude(); //獲取緯度
                    D_longitude = amapLocation.getLongitude(); //獲取經(jīng)度
                    mListener.onLocationChanged(amapLocation);// 顯示系統(tǒng)小藍(lán)點(diǎn)
                    aMap.moveCamera(CameraUpdateFactory.zoomTo(18));
                } else {
                    String errText = "定位失敗," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();
                    Log.e("AmapErr", errText);
                }
            }
        }
        @Override
        public void activate(OnLocationChangedListener listener) {
            mListener = listener;
            if (mlocationClient == null) {
                try {
                    mlocationClient = new AMapLocationClient(this);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                mLocationOption = new AMapLocationClientOption();
                //設(shè)置定位監(jiān)聽(tīng)
                mlocationClient.setLocationListener(this);
                //設(shè)置為高精度定位模式
                mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
                //設(shè)置定位參數(shù)
                mLocationOption.setOnceLocation(true);
                mlocationClient.setLocationOption(mLocationOption);
                // 此方法為每隔固定時(shí)間會(huì)發(fā)起一次定位請(qǐng)求,為了減少電量消耗或網(wǎng)絡(luò)流量消耗,
                // 注意設(shè)置合適的定位時(shí)間的間隔(最小間隔支持為2000ms),并且在合適時(shí)間調(diào)用stopLocation()方法來(lái)取消定位請(qǐng)求
                // 在定位結(jié)束后,在合適的生命周期調(diào)用onDestroy()方法
                // 在單次定位情況下,定位無(wú)論成功與否,都無(wú)需調(diào)用stopLocation()方法移除請(qǐng)求,定位sdk內(nèi)部會(huì)移除
                mlocationClient.startLocation();
            }
        }
        @Override
        public void deactivate() {
            mListener = null;
            if (mlocationClient != null) {
                mlocationClient.stopLocation();
                mlocationClient.onDestroy();
            }
            mlocationClient = null;
        }
        @Override
        public View getInfoWindow(Marker marker) {
            if (infoWindow == null) {
                infoWindow = LayoutInflater.from(this).inflate(R.layout.amap_info_window, null);
            }
            render(marker, infoWindow);
            return infoWindow;
        }
        /**
         * 自定義infoWindow窗口
         */

        private void render(Marker marker, View infoWindow) {
            TextView title = infoWindow.findViewById(R.id.info_window_title);
            TextView content = infoWindow.findViewById(R.id.info_window_content);
            title.setText(marker.getTitle());
            content.setText(marker.getSnippet());
        }
        @Override
        public View getInfoContents(Marker marker) {
            return null;
        }
        @Override
        public boolean onMarkerClick(Marker marker) {
            marker.showInfoWindow();
            mClickMarker = marker;
            mButtonDelete.setVisibility(View.VISIBLE);
            //        aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(marker.getPosition(),18,0,0)));
            return true;
        }
        private void showSettingDialog() {
            LinearLayout wayPointSettings = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_waypointsetting, null);
            final TextView wpAltitude_TV = (TextView) wayPointSettings.findViewById(R.id.altitude);
            RadioGroup speed_RG = (RadioGroup) wayPointSettings.findViewById(R.id.speed);
            RadioGroup actionAfterFinished_RG = (RadioGroup) wayPointSettings.findViewById(R.id.actionAfterFinished);
            RadioGroup heading_RG = (RadioGroup) wayPointSettings.findViewById(R.id.heading);
            wpAltitude_TV.setText(Math.round(altitude) + "");
            if (speed_RG_id != 0) {
                RadioButton radioButton = (RadioButton) speed_RG.findViewById(speed_RG_id);
                radioButton.setChecked(true);
            }
            if (actionAfterFinished_RG_id != 0) {
                RadioButton radioButton = (RadioButton) actionAfterFinished_RG.findViewById(actionAfterFinished_RG_id);
                radioButton.setChecked(true);
            }
            if (heading_RG_id != 0) {
                RadioButton radioButton = (RadioButton) heading_RG.findViewById(heading_RG_id);
                radioButton.setChecked(true);
            }
            speed_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    if (checkedId == R.id.lowSpeed) {
                        mSpeed = 3.0f;
                    } else if (checkedId == R.id.MidSpeed) {
                        mSpeed = 5.0f;
                    } else if (checkedId == R.id.HighSpeed) {
                        mSpeed = 10.0f;
                    }
                    speed_RG_id = checkedId;
                }
            });
            actionAfterFinished_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    MyLog.d("選擇動(dòng)作完成");
                    if (checkedId == R.id.finishNone) {
                        mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;
                        FinishedAction = "0";
                    } else if (checkedId == R.id.finishGoHome) {
                        mFinishedAction = WaypointMissionFinishedAction.GO_HOME;
                        FinishedAction = "1";
                    } else if (checkedId == R.id.finishAutoLanding) {
                        mFinishedAction = WaypointMissionFinishedAction.AUTO_LAND;
                        FinishedAction = "2";
                    } else if (checkedId == R.id.finishToFirst) {
                        mFinishedAction = WaypointMissionFinishedAction.GO_FIRST_WAYPOINT;
                        FinishedAction = "3";
                    }
                    actionAfterFinished_RG_id = checkedId;
                }
            });
            heading_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    MyLog.d("選擇標(biāo)題");
                    if (checkedId == R.id.headingNext) {
                        mHeadingMode = WaypointMissionHeadingMode.AUTO;
                        HeadingMode = "0";
                    } else if (checkedId == R.id.headingInitDirec) {
                        mHeadingMode = WaypointMissionHeadingMode.USING_INITIAL_DIRECTION;
                        HeadingMode = "1";
                    } else if (checkedId == R.id.headingRC) {
                        mHeadingMode = WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER;
                        HeadingMode = "2";
                    } else if (checkedId == R.id.headingWP) {
                        mHeadingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING;
                        HeadingMode = "3";
                    }
                    heading_RG_id = checkedId;
                }
            });
            new AlertDialog.Builder(this)
                    .setTitle("航點(diǎn)設(shè)置")
                    .setView(wayPointSettings)
                    .setNeutralButton("設(shè)置"new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            String altitudeString = wpAltitude_TV.getText().toString();
                            altitude = Integer.parseInt(nulltoIntegerDefalt(altitudeString));
                            MyLog.e("altitude " + altitude);
                            MyLog.e("speed " + mSpeed);
                            MyLog.e("mFinishedAction " + mFinishedAction);
                            MyLog.e("mHeadingMode " + mHeadingMode);
                            configWayPointMission();
                        }
                    })
                    .setCancelable(false)
                    .create()
                    .show();
        }
        String nulltoIntegerDefalt(String value) {
            if (!isIntValue(value))
                value = "0";
            return value;
        }
        boolean isIntValue(String val) {
            try {
                val = val.replace(" """);
                Integer.parseInt(val);
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        private void configWayPointMission() {
            if (waypointMissionBuilder == null) {
                waypointMissionBuilder = new WaypointMission.Builder().finishedAction(mFinishedAction)
                        .headingMode(mHeadingMode)
                        .autoFlightSpeed(mSpeed)
                        .maxFlightSpeed(mSpeed)
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
            } else {
                waypointMissionBuilder.finishedAction(mFinishedAction)
                        .headingMode(mHeadingMode)
                        .autoFlightSpeed(mSpeed)
                        .maxFlightSpeed(mSpeed)
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
            }
            if (waypointMissionBuilder.getWaypointList().size() > 0) {
                for (int i = 0; i < waypointMissionBuilder.getWaypointList().size(); i++) {
                    waypointMissionBuilder.getWaypointList().get(i).altitude = altitude;
                }
            }
            DJIError error = getWaypointMissionOperator().loadMission(waypointMissionBuilder.build());
            if (error == null) {
                if (mLinearLayoutInformation.getVisibility() == View.GONE) {
                    mLinearLayoutInformation.setVisibility(View.VISIBLE);
                }
                mTextViewHeight.setText("高度:" + altitude + "m");
                mTextViewSpeed.setText("速度:" + mSpeed + "m/s");
                mTextViewCount.setText("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
                mTextViewDistance.setText("總距離:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
                mTextViewTime.setText("總時(shí)間:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
                MyLog.d("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
                MyLog.d("總距離:" + waypointMissionBuilder.calculateTotalDistance());
                MyLog.d("總時(shí)間:" + waypointMissionBuilder.calculateTotalTime());
                showToasts("航路點(diǎn)配置成功");
            } else {
                showToasts("航路點(diǎn)配置失敗 " + error.getDescription());
            }
        }
        private void uploadWayPointMission() {
            getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {
                @Override
                public void onResult(DJIError error) {
                    if (error == null) {
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                mButtonSetting.setVisibility(View.GONE);
                                mButtonUpload.setVisibility(View.GONE);
                                mButtonStart.setVisibility(View.VISIBLE);
                                mButtonStop.setVisibility(View.VISIBLE);
                            }
                        });
                        showToasts("任務(wù)上傳成功!");
                        mSQLiteHelper = new SQLiteHelper(SettingRouteActivity.this);
                        MyLog.d("航點(diǎn)值:" + GsonUtil.GsonString(mPointInfo));
                        mSQLiteHelper.doInsert(GsonUtil.GsonString(mPointInfo), altitude, mSpeed, HeadingMode, FinishedAction,
                                waypointMissionBuilder.getWaypointCount(), Math.round(waypointMissionBuilder.calculateTotalDistance()),
                                Math.round(waypointMissionBuilder.calculateTotalTime()), DateUtils.getCurrentDate());
                        mSQLiteHelper.close();
                    } else {
                        showToasts("任務(wù)上傳失敗, error: " + error.getDescription() + " retrying...");
                        getWaypointMissionOperator().retryUploadMission(null);
                    }
                }
            });
        }
        private void startWaypointMission() {
            getWaypointMissionOperator().startMission(new CommonCallbacks.CompletionCallback() {
                @Override
                public void onResult(DJIError error) {
                    showToasts("任務(wù)開(kāi)始: " + (error == null ? "成功" : "失?。?quot; + error.getDescription()));
                }
            });
        }
        private void stopWaypointMission() {
            getWaypointMissionOperator().stopMission(new CommonCallbacks.CompletionCallback() {
                @Override
                public void onResult(DJIError error) {
                    showToasts("任務(wù)暫停: " + (error == null ? "成功" : "失敗" + error.getDescription()));
                }
            });
        }
        @Override
        protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            switch (requestCode) {
                case 101:
                    int Id = data.getExtras().getInt("id");
                    MyLog.d("返回的ID:" + Id);
                    if (Id > -1) {
                        refreshMapPoint(Id);
                    }
                    break;
                case 102:
                    if (data.getData() != null) {
                        Uri uri = data.getData();//得到uri,后面就是將uri轉(zhuǎn)化成file的過(guò)程。
                        String img_path = uri.getPath();
                        try {
                            if (!TextUtils.isEmpty(img_path)) {
                                readKml.parseKml(img_path);
                                addSampleMarker();
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        private void refreshMapPoint(int id) {
            aMap.clear();
            mMarkers.clear();
            mPointInfo.clear();
            mLinearLayoutInformation.setVisibility(View.GONE);
            mButtonFinish.setVisibility(View.GONE);
            mButtonSetting.setVisibility(View.GONE);
            mButtonUpload.setVisibility(View.GONE);
            mButtonStart.setVisibility(View.GONE);
            mButtonStop.setVisibility(View.GONE);
            waypointList.clear();
            mSQLiteHelper = new SQLiteHelper(SettingRouteActivity.this);
            Cursor c = mSQLiteHelper.doSelectWaypoint(id);
            if (c != null) {
                if (c.moveToNext()) {
                    MyLog.d("航點(diǎn):" + "{'pointInfo':" + c.getString(1) + "}");
                    mPointInfo.addAll(GsonUtil.GsonToBean("{'pointInfo':" + c.getString(1) + "}", Root.class).getPointInfo());
                    altitude = c.getFloat(2);
                    mSpeed = c.getFloat(3);
                    switch (c.getString(4)) {
                        case "0":
                            mHeadingMode = WaypointMissionHeadingMode.AUTO;
                            break;
                        case "1":
                            mHeadingMode = WaypointMissionHeadingMode.USING_INITIAL_DIRECTION;
                            break;
                        case "2":
                            mHeadingMode = WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER;
                            break;
                        case "3":
                            mHeadingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING;
                            break;
                        case "4":
                            mHeadingMode = WaypointMissionHeadingMode.TOWARD_POINT_OF_INTEREST;
                            break;
                    }
                    switch (c.getString(5)) {
                        case "0":
                            mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;
                            break;
                        case "1":
                            mFinishedAction = WaypointMissionFinishedAction.GO_HOME;
                            break;
                        case "2":
                            mFinishedAction = WaypointMissionFinishedAction.AUTO_LAND;
                            break;
                        case "3":
                            mFinishedAction = WaypointMissionFinishedAction.GO_FIRST_WAYPOINT;
                            break;
                        case "4":
                            mFinishedAction = WaypointMissionFinishedAction.CONTINUE_UNTIL_END;
                            break;
                    }
                }
            }
            for (int i = 0; i < mPointInfo.size(); i++) {
                showWaypoint(new LatLng(mPointInfo.get(i).getLatitude(), mPointInfo.get(i).getLongitude()));
                Waypoint mWaypoint = new Waypoint(mPointInfo.get(i).getLatitude(), mPointInfo.get(i).getLongitude(), altitude);
                if (waypointMissionBuilder != null) {
                    waypointList.add(mWaypoint);
                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
                } else {
                    waypointMissionBuilder = new WaypointMission.Builder();
                    waypointList.add(mWaypoint);
                    waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
                }
            }
            aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(mPointInfo.get(0).getLatitude(), mPointInfo.get(0).getLongitude()), 1800)));
            ResultconfigWayPointMission();
            getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {
                @Override
                public void onResult(DJIError djiError) {
                    if (djiError == null) {
                        showToasts("獲取任務(wù)成功!");
                    }
                }
            });
        }
        private void showWaypoint(LatLng point) {
            MarkerOptions markerOptions = new MarkerOptions();
            markerOptions.position(point);
            markerOptions.title("航點(diǎn)" + (mMarkers.size() + 1));
            markerOptions.snippet("事件:");
            markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
            markerOptions.infoWindowEnable(true);
            Marker marker = aMap.addMarker(markerOptions);
            mMarkers.put(mMarkers.size(), marker);
            marker.showInfoWindow();
            if (mMarkers.size() > 0) {
                mLatLng.clear();
                PolylineOptions PolylineOptions = new PolylineOptions();
                for (int i = 0; i < mMarkers.size(); i++) {
                    mLatLng.add(mMarkers.get(i).getPosition());
                }
                PolylineOptions.addAll(mLatLng);
                PolylineOptions.width(10);
                PolylineOptions.color(Color.argb(255111));
                aMap.addPolyline(PolylineOptions);
            }
        }
        private void ResultconfigWayPointMission() {
            if (waypointMissionBuilder == null) {
                waypointMissionBuilder = new WaypointMission.Builder().finishedAction(mFinishedAction)
                        .headingMode(mHeadingMode)
                        .autoFlightSpeed(mSpeed)
                        .maxFlightSpeed(mSpeed)
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
            } else {
                waypointMissionBuilder.finishedAction(mFinishedAction)
                        .headingMode(mHeadingMode)
                        .autoFlightSpeed(mSpeed)
                        .maxFlightSpeed(mSpeed)
                        .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
            }
            if (waypointMissionBuilder.getWaypointList().size() > 0) {
                for (int i = 0; i < waypointMissionBuilder.getWaypointList().size(); i++) {
                    waypointMissionBuilder.getWaypointList().get(i).altitude = altitude;
                }
            }
            DJIError error = getWaypointMissionOperator().loadMission(waypointMissionBuilder.build());
            if (error == null) {
                if (mLinearLayoutInformation.getVisibility() == View.GONE) {
                    mLinearLayoutInformation.setVisibility(View.VISIBLE);
                }
                mButtonStart.setVisibility(View.VISIBLE);
                mButtonStop.setVisibility(View.VISIBLE);
                mTextViewHeight.setText("高度:" + altitude + "m");
                mTextViewSpeed.setText("速度:" + mSpeed + "m/s");
                mTextViewCount.setText("航點(diǎn)數(shù):" + waypointMissionBuilder.getWaypointCount());
                mTextViewDistance.setText("總距離:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
                mTextViewTime.setText("總時(shí)間:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
            }
        }
        private void addSampleMarker() {
            if (ReadKml.addSampleSuccess) {
                aMap.clear();
                mMarkers.clear();
                mPointInfo.clear();
                waypointList.clear();
                if (mLinearLayoutInformation.getVisibility() == View.VISIBLE) {
                    mLinearLayoutInformation.setVisibility(View.GONE);
                }
                mButtonFinish.setVisibility(View.GONE);
                mButtonSetting.setVisibility(View.GONE);
                mButtonUpload.setVisibility(View.GONE);
                mButtonStart.setVisibility(View.GONE);
                mButtonStop.setVisibility(View.GONE);
                for (int i = 0; i < sampleList.size(); i++) {
                    showWaypoint(new LatLng(sampleList.get(i).getX(), sampleList.get(i).getY()));
                    Waypoint mWaypoint = new Waypoint(sampleList.get(i).getX(), sampleList.get(i).getY(), altitude);
                    //Add Waypoints to Waypoint arraylist;
                    if (waypointMissionBuilder != null) {
                        waypointList.add(mWaypoint);
                        waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
                    } else {
                        waypointMissionBuilder = new WaypointMission.Builder();
                        waypointList.add(mWaypoint);
                        waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
                    }
                }
                aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(sampleList.get(0).getX(), sampleList.get(0).getY()), 1800)));
                showSettingDialog();
                mButtonSetting.setVisibility(View.VISIBLE);
                mButtonUpload.setVisibility(View.VISIBLE);
            } else {
                Log.d("MainActivity""addSampleSuccess is false or aMap is null");
            }
        }

3

航線管理

創(chuàng)建activity_waypoint.xml和WaypointActivity文件。

activity_waypoint.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.WaypointActivity"
    android:orientation="vertical"
    android:background="@drawable/shape_corner_eight">

    <include
        android:id="@+id/layout_waypoint"
        layout="@layout/activity_toolbar">
</include>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#5B6782"
        android:layout_marginTop="1dp"
        android:layout_marginRight="20dp"
        android:layout_marginLeft="20dp"
        >
</View>
    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_waypoint"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginRight="20dp"
        android:layout_marginLeft="20dp">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>

WaypointActivity

@Layout(R.layout.activity_waypoint)
public class WaypointActivity extends BaseActivity implements View.OnClickListener {
    @BindView(R.id.layout_waypoint)
    View mViewLayoutToolbar;
    @BindView(R.id.ll_waypoint)
    LinearLayout mLinearLayout;
    @BindView(R.id.tv_toolbar_title)
    TextView mTextViewToolbarTitle;
    @BindView(R.id.rv_waypoint)
    RecyclerView mRecyclerView;
    private SQLiteHelper mSQLiteHelper;
    private List<WaypointInfo> mWaypointInfo = new ArrayList<>();
    private WaypointAdapter mWaypointAdapter;
    private List<Integer> mWaypointId = new ArrayList<>();
    private String StrId = "";
    @Override
    public void initViews() {
        mLinearLayout.setVisibility(View.VISIBLE);
        mTextViewToolbarTitle.setText("航線管理");
        MyStatic.isChoose = false;
    }
    @Override
    public void initDatas() {
        mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);
        Cursor c = mSQLiteHelper.doSelect();
        if (c!=null){
            while (c.moveToNext()){
                mWaypointInfo.add(new WaypointInfo(c.getInt(0),c.getString(1),c.getFloat(2),c.getFloat(3),
                        c.getString(4),c.getString(5),c.getString(6),c.getInt(7),c.getInt(8),
                        c.getInt(9),c.getString(10)));
            }
        }
        c.close();
        mSQLiteHelper.close();
        mWaypointAdapter = new WaypointAdapter(R.layout.item_waypoint);
        mWaypointAdapter.setNewData(mWaypointInfo);
        initRv(mRecyclerView,mWaypointAdapter);
        mWaypointAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                Intent intent = new Intent();
                intent.putExtra("id", mWaypointInfo.get(position).getId());
                setResult(RESULT_OK, intent);
                finish();
            }
        });
        mWaypointAdapter.setOnCheckboxCheckedListener(new WaypointAdapter.OnCheckboxCheckedListener() {
            @Override
            public void OnCheckboxChecked(boolean isCheck, int position) {
                if (isCheck){
                    mWaypointId.add(position);
                }else {
                    if (mWaypointId.contains(position)){
                        mWaypointId.remove(position);
                    }
                }
            }
        });
    }
    @Override
    protected void requestData() {
    }
    @OnClick({R.id.img_way_choose,R.id.img_way_delete,R.id.img_back})
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.img_way_choose:
                if (MyStatic.isChoose){
                    MyStatic.isChoose = false;
                }else {
                    MyStatic.isChoose = true;
                }
                if (mWaypointAdapter!=null){
                    mWaypointAdapter.notifyDataSetChanged();
                }
                break;
            case R.id.img_way_delete:
                if (mWaypointId.size() > 0){
                    for (int i = 0; i < mWaypointId.size(); i++){
                        StrId += mWaypointInfo.get(mWaypointId.get(i)).getId()+",";
                    }
                    if (!TextUtils.isEmpty(StrId)){
                        StrId = StrId.substring(0,StrId.length()-1);
                        mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);
                        mSQLiteHelper.doDelete(StrId);
                        mSQLiteHelper.close();
                        for (int j = 0; j < mWaypointId.size(); j++){
                            mWaypointInfo.remove(mWaypointId.get(j).intValue());
                        }
                        if (mWaypointAdapter!=null){
                            mWaypointId.clear();
                            MyStatic.isChoose = false;
                            mWaypointAdapter.setNewData(mWaypointInfo);
                        }
                    }
                }else {
                    showToasts("請(qǐng)先選擇刪除的航線!");
                }
                break;
            case R.id.img_back:
                Intent intent = new Intent();
                intent.putExtra("id", -1);
                setResult(RESULT_OK, intent);
                finish();
                break;
        }
    }

以上代碼僅供參考,如果想了解更多的大疆無(wú)人機(jī)二次開(kāi)發(fā)過(guò)程可以私信我,源代碼因?yàn)樯婕暗缴虡I(yè)使用不能給大家共享,有什么問(wèn)題我可以幫你解決。


*博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請(qǐng)聯(lián)系工作人員刪除。



關(guān)鍵詞: Mobile 大疆無(wú)人機(jī)

相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉