一个简单智能停车APP——主功能界面

一个简单智能停车APP——主功能界面,第1张

概述一个简单智能停车APP功能介绍代码详解总结功能介绍实现了点击扫一扫跳转到微信扫一扫,支付宝扫一扫。点击搜索地名,跳转百度地图,并语言播报其中专享福利与附近车位分别是横向RecyclerView和竖向滑动RecyclerView点击附近车位的任意子项可以直接根据子项上的地址直 @H_301_3@

一个简单智能停车APP功能介绍代码详解总结

功能介绍

实现了点击扫一扫跳转到微信扫一扫,支付宝扫一扫。
点击搜索地名,跳转百度地图,并语言播报
其中专享福利与附近车位分别是横向RecyclerVIEw和竖向滑动RecyclerVIEw
点击附近车位的任意子项可以直接根据子项上的地址直接导航(前提必须安装百度地图)

效果图如下:

需要在清单文件声明如下权限:

 <!-- 这个权限用于进行网络定位 -->    <uses-permission androID:name="androID.permission.ACCESS_COARSE_LOCATION" /> <!-- 这个权限用于访问GPS定位 -->    <uses-permission androID:name="androID.permission.ACCESS_FINE_LOCATION" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->    <uses-permission androID:name="androID.permission.ACCESS_WIFI_STATE" /> <!-- 获取运营商信息,用于支持提供运营商信息相关的接口 -->    <uses-permission androID:name="androID.permission.ACCESS_NETWORK_STATE" /> <!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位 -->    <uses-permission androID:name="androID.permission.CHANGE_WIFI_STATE" /> <!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据 -->    <uses-permission androID:name="androID.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 访问网络,网络定位需要上网 -->    <uses-permission androID:name="androID.permission.INTERNET" /> <!-- 允许挂载和反挂载文件系统可移动存储 -->    <uses-permission androID:name="androID.permission.MOUNT_UNMOUNT_fileSYstemS" /> <!-- 允许程序读取底层系统日志文件 -->    <uses-permission androID:name="androID.permission.READ_LOGS" /> <!-- 允许访问振动设备 -->    <uses-permission androID:name="androID.permission.VIBRATE" /> <!-- 允许使用PowerManager的 WakeLocks保持进程在休眠时从屏幕消失 -->    <uses-permission androID:name="androID.permission.WAKE_LOCK" /> <!-- 允许程序读取或写入系统设置 -->    <uses-permission androID:name="androID.permission.WRITE_SETTINGS" /> <!-- androID 9.0上使用前台服务,需要添加权限 -->    <uses-permission androID:name="androID.permission.FOREGROUND_SERVICE" /> <!-- 用于读取手机当前的状态 -->    <uses-permission androID:name="androID.permission.READ_PHONE_STATE" /> <!-- 读取缓存数据 -->    <uses-permission androID:name="androID.permission.READ_EXTERNAL_STORAGE" /> <!-- 获取模拟定位信息 -->    <uses-permission androID:name="androID.permission.ACCESS_MOCK_LOCATION" />    <uses-permission androID:name="androID.permission.PACKAGE_USAGE_STATS" /> <!-- 获取应用启动次数权限 -->    <uses-permission androID:name="androID.permission.RECORD_AUdio" /> <!-- 语音权限 -->    <uses-permission androID:name="androID.permission.PERMISSIONS_STORAGE" /> <!-- 手机定位信息,用来为语义等功能提供定位,提供更精准的服务 -->    <!-- 如需使用人脸识别,还要添加:摄相头权限,拍照需要用到 -->    <uses-permission androID:name="androID.permission.CAMERA" />    <uses-feature androID:name="androID.harDWare.Camera" />    <uses-feature androID:name="androID.harDWare.Camera.autofocus" />    <uses-permission androID:name="androID.permission.RECEIVE_SMS" /> <!-- GUI自动填充验证码功能(非必须) -->    <uses-permission androID:name="androID.permission.READ_SMS" />    <uses-permission androID:name="androID.permission.ACCESS_NOTIFICATION_POliCY"/>
代码详解

XML布局代码如下:

<?xml version="1.0" enCoding="utf-8"?><androIDx.drawerlayout.Widget.DrawerLayout xmlns:tools="http://schemas.androID.com/tools"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    xmlns:androID="http://schemas.androID.com/apk/res/androID"    xmlns:app="http://schemas.androID.com/apk/res-auto"><linearLayout    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"    androID:orIEntation="vertical">    <ImageVIEw        androID:ID="@+ID/Function_goback"        androID:layout_wIDth="20dp"        androID:layout_height="20dp"        androID:layout_marginleft="@dimen/XXSmall"        androID:layout_margintop="@dimen/XXSmall"        androID:scaleType="fitCenter"        androID:src="@drawable/goback" />    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="50dp"        androID:background="@drawable/information1"        androID:orIEntation="vertical"        androID:layout_marginleft="10dp"        androID:layout_marginRight="10dp"       >        <linearLayout            androID:layout_wIDth="match_parent"            androID:layout_height="wrap_content"            androID:orIEntation="horizontal">        <linearLayout            androID:layout_wIDth="280dp"            androID:layout_height="wrap_content"            androID:layout_marginleft="20dp"            androID:layout_margintop="@dimen/XXSmall"            androID:background="@drawable/searchbar"            androID:orIEntation="horizontal">            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="10dp"                androID:layout_margintop="2dp"                androID:text="株洲市" />            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="5dp"                androID:layout_margintop="5dp"                androID:scaleType="fitCenter"                androID:src="@drawable/dropdown" />            <Imagebutton                androID:ID="@+ID/Search"                androID:layout_wIDth="18dp"                androID:layout_height="20dp"                androID:layout_marginleft="10dp"                androID:layout_margintop="10dp"                androID:background="#00000000"                androID:scaleType="fitCenter"                androID:src="@drawable/search" />            <EditText                androID:ID="@+ID/SearchPlace"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="10dp"                androID:layout_margintop="0dp"                androID:hint="输入目的地寻找停车位"                androID:textSize="12sp" />        </linearLayout>            <linearLayout                androID:layout_wIDth="match_parent"                androID:layout_height="wrap_content">                <ImageVIEw                    androID:ID="@+ID/Scan"                    androID:layout_wIDth="23dp"                    androID:layout_height="30dp"                    androID:layout_marginleft="@dimen/XSmall"                    androID:layout_margintop="@dimen/XSmall"                    androID:background="#00000000"                    androID:scaleType="fitCenter"                    androID:src="@drawable/scan" />            </linearLayout>        </linearLayout>    </linearLayout>    <!--功能模块-->    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_marginleft="20dp"        androID:layout_margintop="10dp"        androID:orIEntation="horizontal">        <!--图标-->        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/totalcar"/>            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="车位掌柜"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/money1" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="停车缴费"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/cards1" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="月卡续费"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/submoney" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="优惠专区"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/welfare" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="新人福利"                androID:textSize="10sp" />        </linearLayout>    </linearLayout>    <!--第二模块-->    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:layout_marginleft="20dp"        androID:layout_margintop="10dp"        androID:orIEntation="horizontal">        <!--图标-->        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/signin1" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="积分签到"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/people123" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="省钱小蜜"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/zhangdan" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="我的账单"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/pay" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="无感支付"                androID:textSize="10sp" />        </linearLayout>        <linearLayout            androID:layout_wIDth="0dp"            androID:layout_height="wrap_content"            androID:layout_weight="1"            androID:orIEntation="vertical">            <ImageVIEw                androID:layout_wIDth="30dp"                androID:layout_height="30dp"                androID:layout_marginleft="4dp"                androID:scaleType="fitCenter"                androID:src="@drawable/fAPIao" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_margintop="5dp"                androID:text="电子发票"                androID:textSize="10sp" />        </linearLayout>    </linearLayout>    <!--登陆小模块-->    <linearLayout        androID:layout_wIDth="wrap_content"        androID:layout_height="50dp"        androID:layout_marginleft="20dp"        androID:layout_margintop="20dp"        androID:background="@drawable/littlelogin"        androID:orIEntation="horizontal">        <TextVIEw            androID:ID="@+ID/LoginStatusText"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_marginleft="10dp"            androID:layout_margintop="10dp"            androID:text="登陆“布道者”智能停车,停车缴费更便捷"            androID:textcolor="#ffffff"            androID:textSize="10sp" />        <button            androID:ID="@+ID/IntentLogin"            androID:layout_wIDth="90dp"            androID:layout_height="30dp"            androID:layout_marginleft="30dp"            androID:layout_margintop="10dp"            androID:background="@drawable/loginbutton"            androID:text="立即登陆"            androID:textcolor="#436EEE" />    </linearLayout>    <!--专享福利-->    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:orIEntation="vertical">        <!--板块1-->        <linearLayout            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_margintop="20dp"            androID:orIEntation="horizontal">            <VIEw                androID:layout_wIDth="3dp"                androID:layout_height="20dp"                androID:layout_marginleft="10dp"                androID:background="#40E0D0" />            <TextVIEw                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_marginleft="5dp"                androID:text="专享福利"                androID:textcolor="#000" />        </linearLayout><androIDx.recyclervIEw.Widget.RecyclerVIEw    androID:ID="@+ID/HorizontalRecyclerVIEw"    androID:layout_wIDth="match_parent"    androID:layout_height="wrap_content"    androID:layout_margintop="@dimen/XSmall"/>    </linearLayout>    <linearLayout        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_margintop="@dimen/XSmall"        androID:orIEntation="horizontal">        <VIEw            androID:layout_wIDth="3dp"            androID:layout_height="20dp"            androID:layout_marginleft="10dp"            androID:background="#40E0D0" />        <TextVIEw            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_marginleft="5dp"            androID:text="附近车位"            androID:textcolor="#000" />    </linearLayout>    <androIDx.recyclervIEw.Widget.RecyclerVIEw        androID:ID="@+ID/MyRecyclerVIEw"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:layout_margintop="10dp"        androID:descendantFocusability="blocksDescendants" /></linearLayout>    <com.Google.androID.material.navigation.NavigationVIEw        androID:ID="@+ID/informationManage"        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        app:headerLayout="@layout/information_head_item"        app:menu="@menu/setting_menu"        androID:layout_gravity="left"        />    </androIDx.drawerlayout.Widget.DrawerLayout>

首先判断是否声明权限

if (ContextCompat.checkSelfPermission( Function.this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED) {            PermissionList.add( Manifest.permission.ACCESS_FINE_LOCATION );        }        if (ContextCompat.checkSelfPermission( Function.this, Manifest.permission.READ_PHONE_STATE ) != PackageManager.PERMISSION_GRANTED) {            PermissionList.add( Manifest.permission.READ_PHONE_STATE );        }        if (ContextCompat.checkSelfPermission( Function.this, Manifest.permission.WRITE_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED) {            PermissionList.add( Manifest.permission.WRITE_EXTERNAL_STORAGE );        }        if (!PermissionList.isEmpty()) {            String[] Permissions = PermissionList.toArray( new String[PermissionList.size()] );//转化为数组            ActivityCompat.requestPermissions( Function.this, Permissions, 1 );//一次性申请权限        } else {            /*****************如果权限都已经声明,开始配置参数*****************/            requestLocation();        }

百度地图参数配置

 /*******************初始化百度地图各种参数*******************/    private voID initLocation() {        LocationClIEntoption option = new LocationClIEntoption();        option.setLocationMode(LocationClIEntoption.LocationMode.Hight_Accuracy);        /**可选,设置定位模式,默认高精度LocationMode.Hight_Accuracy:高精度;         * LocationMode. Battery_Saving:低功耗;LocationMode. Device_Sensors:仅使用设备;*/        option.setCoorType("bd09ll");        /**可选,设置返回经纬度坐标类型,默认gcj02gcj02:国测局坐标;bd09ll:百度经纬度坐标;bd09:百度墨卡托坐标;         海外地区定位,无需设置坐标类型,统一返回wgs84类型坐标*/        option.setScanSpan(3000);        /**可选,设置发起定位请求的间隔,int类型,单位ms如果设置为0,则代表单次定位,即仅定位一次,默认为0如果设置非0,需设置1000ms以上才有效*/        option.setopenGps(true);        /**可选,设置是否使用gps,默认false使用高精度和仅用设备两种定位模式的,参数必须设置为true*/        option.setLocationNotify(true);        /**可选,设置是否当GPS有效时按照1S/1次频率输出GPS结果,默认false*/        option.setIgnoreKillProcess(false);        /**定位SDK内部是一个service,并放到了独立进程。设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)*/        option.SetIgnoreCacheException(false);        /**可选,设置是否收集Crash信息,默认收集,即参数为false*/        option.setIsNeedAltitude(true);/**设置海拔高度*/        option.setWifiCacheTimeOut(5 * 60 * 1000);        /**可选,7.2版本新增能力如果设置了该接口,首次启动定位时,会先判断当前WiFi是否超出有效期,若超出有效期,会先重新扫描WiFi,然后定位*/        option.setEnableSimulateGps(false);        /**可选,设置是否需要过滤GPS仿真结果,默认需要,即参数为false*/        option.setIsNeedAddress(true);        /**可选,设置是否需要地址信息,默认不需要*/        clIEnt.setLocoption(option);        /**mLocationClIEnt为第二步初始化过的LocationClIEnt对象需将配置好的LocationClIEntoption对象,通过setLocoption方法传递给LocationClIEnt对象使用*/    }

判断是否安装了百度地图,然后进行跳转搜索

/****************判断百度地图是否安装***************/    public static boolean isBaIDuMAPInstalled(){        return isInstallPackage(BAIDUMAPPACKAGE);    }    private static boolean isInstallPackage(String packagename) {        return new file("/data/data/" + packagename).exists();    }

跳转以及语言播报

 Search.setonClickListener( new VIEw.OnClickListener() {         @OverrIDe         public voID onClick(VIEw v) {             //根据搜索栏搜索的地点,然后根据自身的经纬度,进行查询             String EndAddress = SearchPlace.getText().toString();             String SpeakContent = "本次导航从当前位置前往"+EndAddress;             String Zeng = "警告警告检测到周围有曾大屁出现快疏散人群她要放屁了她要放屁了她要放屁了重要的事情说三遍";             if (TTS != null && !TTS.isspeaking()) {                 TTS.setPitch(0.0f);// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规                 if (EndAddress.equals( "曾大屁" ))                 {                     TTS.speak(Zeng,TextToSpeech.QUEUE_FLUSH, null);                 }else {                     TTS.speak( SpeakContent, TextToSpeech.QUEUE_FLUSH, null );                 }             }else {                 Toast.makeText( Function.this, "语音助手错误", Toast.LENGTH_LONG ).show();             }             if (isBaIDuMAPInstalled()) {                 Navigation(EndAddress);             } else {                 // 未安装                 Toast.makeText( Function.this, "您尚未安装百度地图", Toast.LENGTH_LONG ).show();             }         }     } );    }

语言播报类初始化

    /****************语音助手监听事件***************/    class InitTTS implements TextToSpeech.OnInitListener{        @OverrIDe        public voID onInit(int status) {            if (status == TextToSpeech.SUCCESS) {                int result = TTS.setLanguage( Locale.CHINA);                if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {                    Toast.makeText( Function.this, "数据丢失或不支持", Toast.LENGTH_SHORT).show();                }            }        }    }

接下来介绍跳转到微信扫一扫和支付宝扫一扫
首先判断本地是否安装了两个软件,然后进行跳转

 /****************监测是否安装了微信***************/    public static boolean CheckWeiXinInstalled(Context context) {        final PackageManager packageManager = context.getPackageManager();// 获取packagemanager        List<PackageInfo> pinfo = packageManager.getInstalledPackages( 0 );// 获取所有已安装程序的包信息        if (pinfo != null) {            for (int i = 0; i < pinfo.size(); i++) {                String pn = pinfo.get( i ).packagename;                if (pn.equals( "com.tencent.mm" )) {                    return true;                }            }        }        return false;    }    /****************监测支付宝是否安装***************/    public static boolean CheckAliPayInstalled(Context context) {        Uri uri = Uri.parse("alipays://platformAPI/startApp");        Intent intent = new Intent(Intent.ACTION_VIEW, uri);        Componentname componentname = intent.resolveActivity(context.getPackageManager());        return componentname != null;    }
/****************跳转到微信扫一扫***************/    private voID toWeiXinScan(Context context){        try {            Intent intent = Function.this.getPackageManager().getLaunchIntentForPackage( "com.tencent.mm" );            intent.putExtra( "LauncherUI.From.Scaner.Shortcut", true );            startActivity( intent );        } catch (Exception e) {            Toast.makeText( Function.this, "没有安装微信", Toast.LENGTH_SHORT ).show();        }    }    /****************跳转到支付宝扫一扫***************/    public static voID toAliPayScan(Context context)    {        try        {            Uri uri = Uri.parse("alipayqr://platformAPI/startapp?saID=10000007");            Intent intent = new Intent(Intent.ACTION_VIEW, uri);            context.startActivity(intent);        } catch (Exception e)        {            Toast.makeText(context, "打开失败,请检查是否安装了支付宝", Toast.LENGTH_SHORT).show();        }    }

整体代码如下:

package com.example.Imformation;import androIDx.annotation.NonNull;import androIDx.annotation.Nullable;import androIDx.appcompat.app.AppCompatActivity;import androIDx.core.app.ActivityCompat;import androIDx.core.content.ContextCompat;import androIDx.core.content.fileProvIDer;import androIDx.recyclervIEw.Widget.linearlayoutmanager;import androIDx.recyclervIEw.Widget.RecyclerVIEw;import androIDx.vIEwpager.Widget.VIEwPager;import androID.Manifest;import androID.app.Activity;import androID.content.Componentname;import androID.content.ContentValues;import androID.content.Context;import androID.content.Intent;import androID.content.pm.PackageInfo;import androID.content.pm.PackageManager;import androID.content.res.Resources;import androID.graphics.Bitmap;import androID.graphics.drawable.BitmapDrawable;import androID.graphics.drawable.Drawable;import androID.net.Uri;import androID.os.Build;import androID.os.Bundle;import androID.os.Environment;import androID.provIDer.MediaStore;import androID.speech.tts.TextToSpeech;import androID.speech.tts.UtteranceProgressListener;import androID.vIEw.Gravity;import androID.vIEw.KeyEvent;import androID.vIEw.LayoutInflater;import androID.vIEw.MenuItem;import androID.vIEw.VIEw;import androID.vIEw.VIEwGroup;import androID.Widget.button;import androID.Widget.EditText;import androID.Widget.Imagebutton;import androID.Widget.ImageVIEw;import androID.Widget.PopupWindow;import androID.Widget.SearchVIEw;import androID.Widget.TextVIEw;import androID.Widget.Toast;import com.baIDu.location.BDLocation;import com.baIDu.location.BDLocationListener;import com.baIDu.location.LocationClIEnt;import com.baIDu.location.LocationClIEntoption;import com.baIDu.mapAPI.SDKInitializer;import com.baIDu.mapAPI.map.MapStatusUpdate;import com.baIDu.mapAPI.map.MapStatusUpdateFactory;import com.baIDu.mapAPI.map.MyLocationData;import com.baIDu.mapAPI.model.LatLng;import com.baIDu.mapAPI.search.geocode.ReverseGeoCodeResult;import com.example.Adapter.MyPagerAdapter;import com.example.Adapter.MyRecyclerVIEwHorizontal;import com.example.Adapter.MyRecyclerVIEwTools;import com.example.Adapter.RecyclerVIEwHorizontalAdapter;import com.example.AdvanceBooking.Booking;import com.example.litepal.Account;import com.example.LoginPackage.Login;import com.example.LoginPackage.Registerinformation;import com.example.Order.OrderInterface;import com.example.Sharedparking.ParkingType;import com.example.Tools.fileManager;import com.example.Tools.ParkingTools;import com.example.Tools.PermissionManager;import com.example.intelligentparking.MainActivity;import com.example.intelligentparking.R;import com.Google.androID.material.navigation.NavigationVIEw;import com.zxy.tiny.Tiny;import com.zxy.tiny.callback.fileWithBitmapCallback;import org.litepal.litePal;import java.io.file;import java.io.IOException;import java.util.ArrayList;import java.util.IllegalFormatCodePointException;import java.util.List;import java.util.Locale;import de.hdodenhof.circleimagevIEw.circleimageVIEw;public class Function extends AppCompatActivity {    private LocationClIEnt clIEnt;    private VIEw vIEw = null;    private VIEw vIEwSex = null;    private button ToCamera,tophoto,ToExit,Exit;    private PopupWindow popupWindow;    private RecyclerVIEw MyRecyclerVIEw,HorizontalRecyclerVIEw;    private MyRecyclerVIEwTools addpter;    private RecyclerVIEwHorizontalAdapter HorizontalAdapter;    private EditText SearchPlace;    private Imagebutton Search;    private ImageVIEw UserIcon,GoBack;    private button IntentLoginInterface;    private VIEwPager vIEwPager;    private TextToSpeech TTS = null;    private TextVIEw LoginTextStatus,LoginStatusTiltle,LoginStatusSubTiltle;    private ImageVIEw Scan;    private NavigationVIEw InfarmationManage;    private circleimageVIEw Image;    private TextVIEw ID;    private double Latitude = 0;    private double Longitude = 0;    public static final String BAIDUMAPPACKAGE = "com.baIDu.BaIDuMap"; // 百度地图包名    private List<ParkingTools> List = new ArrayList<>();    private List<MyRecyclerVIEwHorizontal> horizontallist = new ArrayList<>(  );    private static int OPENgalLERY = 1;    private static int OPENCAMERA = 2;    private static final String[] StatementPermisson = {Manifest.permission.CAMERA,Manifest.permission.WRITE_EXTERNAL_STORAGE};    private static final int PERMISSION_CAMERA_REQUEST_CODE = 3;    /*******************************以下为横向RecyclerVIEw数据************************************/    public int[] BigImage = {          R.drawable.zhuanpam,          R.drawable.money20,          R.drawable.stopcar,          R.drawable.huafei20,          R.drawable.meituan,          R.drawable.money100    };    public int[] Smallimage = {            R.drawable.go,            R.drawable.go,            R.drawable.go,            R.drawable.go,            R.drawable.go,            R.drawable.go    };    public String[] BigTitle = {           "幸运大转盘",            "20元停车券",            "霸王免费停",            "话费充值券",            "最高88神券",            "邀好友拿100"    };    public String[] SmallTitle = {            "天天抽好礼",            "积分免费兑",            "赢免费停车",            "三网全通用",            "外卖吃不完",            "天天拿不完"    };    /*******************************以上为横向RecyclerVIEw数据************************************/    /*******************以下为停车位RecyclerVIEw数据********************/    public  String[] StringBigPlace = {            "工人文化宫停车场",            "停车场(康复路)",            "停车场(水木兰庭东南)",            "圣华名城停车场",            "嵘兴.圣华名城停车场",            "中车停车场",            "停车场(杉塘路)"    };    private String[] StringSmallPlace = {            "田心大道52号附近",            "响石岭步行街与建设北路交叉口东北100米",            "建设北路200号附近",            "建设北路36号附近",            "杉塘路13号附近",            "田心大道52号文化广场",            "杉塘路与杉木塘路交叉口西南150米"    };    private String[] Stringdistance = {            "232m",            "1.8km",            "1.9km",            "1.9km",            "2.0km",            "233m",            "2.1km"    };    private int[] IntIcons = {            R.drawable.lubiao,            R.drawable.lubiao,            R.drawable.lubiao,            R.drawable.lubiao,            R.drawable.lubiao,            R.drawable.lubiao,            R.drawable.lubiao    };    /*******************以上为RecyclerVIEw数据********************/    @OverrIDe    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate( savedInstanceState );        /*******************一定要在setContentVIEw()前调用********************/        SDKInitializer.initialize( getApplicationContext() );        clIEnt = new LocationClIEnt( getApplicationContext() );//获取全局Context        clIEnt.registerLocationListener( new MyBaIDuMap() );//注册一个定位监听器,获取位置信息,回调此定位监听器        setContentVIEw( R.layout.function );        InitData();        InitHorizontalData();        InitVIEw();        InitAdapter();        InitHorizontalAdapter();        Listener();        //UpdateLayout();        InitNavigationVIEw();        ShowPopupwindows();        /*******************语音助手初始化*******************/        TTS = new TextToSpeech( Function.this,new InitTTS() );        /*******************将所有需要判断的权限保存到一个数组中,统一一起判断*******************/        List<String> PermissionList = new ArrayList<>();        //判断权限是否授权        if (ContextCompat.checkSelfPermission( Function.this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED) {            PermissionList.add( Manifest.permission.ACCESS_FINE_LOCATION );        }        if (ContextCompat.checkSelfPermission( Function.this, Manifest.permission.READ_PHONE_STATE ) != PackageManager.PERMISSION_GRANTED) {            PermissionList.add( Manifest.permission.READ_PHONE_STATE );        }        if (ContextCompat.checkSelfPermission( Function.this, Manifest.permission.WRITE_EXTERNAL_STORAGE ) != PackageManager.PERMISSION_GRANTED) {            PermissionList.add( Manifest.permission.WRITE_EXTERNAL_STORAGE );        }        if (!PermissionList.isEmpty()) {            String[] Permissions = PermissionList.toArray( new String[PermissionList.size()] );//转化为数组            ActivityCompat.requestPermissions( Function.this, Permissions, 1 );//一次性申请权限        } else {            /*****************如果权限都已经声明,开始配置参数*****************/            requestLocation();        }        /*******************点击搜索按钮之后,进行语言播报*******************/     Search.setonClickListener( new VIEw.OnClickListener() {         @OverrIDe         public voID onClick(VIEw v) {             //根据搜索栏搜索的地点,然后根据自身的经纬度,进行查询             String EndAddress = SearchPlace.getText().toString();             String SpeakContent = "本次导航从当前位置前往"+EndAddress;             String Zeng = "警告警告检测到周围有曾大屁出现快疏散人群她要放屁了她要放屁了她要放屁了重要的事情说三遍";             if (TTS != null && !TTS.isspeaking()) {                 TTS.setPitch(0.0f);// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规                 if (EndAddress.equals( "曾大屁" ))                 {                     TTS.speak(Zeng,TextToSpeech.QUEUE_FLUSH, null);                 }else {                     TTS.speak( SpeakContent, TextToSpeech.QUEUE_FLUSH, null );                 }             }else {                 Toast.makeText( Function.this, "语音助手错误", Toast.LENGTH_LONG ).show();             }             if (isBaIDuMAPInstalled()) {                 Navigation(EndAddress);             } else {                 // 未安装                 Toast.makeText( Function.this, "您尚未安装百度地图", Toast.LENGTH_LONG ).show();             }         }     } );    }    /******打开相册*/    public  voID opengallery() {        Intent picture = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);        startActivityForResult(picture, OPENgalLERY);    }    /************需要动态申请权限************/    /*********第一次需要动态申请,然后d出一个提示是否允许启动相机********/    private voID requestPermission() {        // AndroID6.0开始, 即当API大于等于 23 时,才动态申请权限        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {            this.requestPermissions(StatementPermisson, PERMISSION_CAMERA_REQUEST_CODE);        }    }/*****打开相机*/    public voID OpenCamera(){        try {            Intent intent = new Intent();            intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);            file file = fileManager.createfileIfNeed("filepath.png");            Uri uri;            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {                uri = Uri.fromfile(file);            } else {                uri = fileProvIDer.getUriForfile(this, "link.androID.file.provIDer", file);            }            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);            intent.putExtra(MediaStore.EXTRA_VIDEO_QUAliTY, 1);            startActivityForResult(intent, 1);        }catch (IOException e){            e.printstacktrace();        }    }    /********获取Popupwindows布局视图,并对其中选项进行监听事件书写*/    private voID ShowPopupwindows() {        //获取布局        vIEw = LayoutInflater.from( Function.this).inflate( R.layout.popup_image,null,false );        ToCamera = vIEw.findVIEwByID( R.ID.ToCamera ); //跳转相机        tophoto = vIEw.findVIEwByID( R.ID.tophoto );//跳转相册        ToExit = vIEw.findVIEwByID( R.ID.ToExit );//退出        popupWindow = new PopupWindow( vIEw, VIEwGroup.LayoutParams.MATCH_PARENT,VIEwGroup.LayoutParams.WRAP_CONTENT );        popupWindow.setFocusable( true ); //获取焦点        popupWindow.setBackgroundDrawable( new BitmapDrawable(  ) );        popupWindow.setoutsIDetouchable( true ); //点击外面地方,取消        popupWindow.settouchable( true ); //允许点击        popupWindow.setAnimationStyle( R.style.MyPopupWindow ); //设置动画        ToExit.setonClickListener( new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                popupWindow.dismiss();            }        } );        ToCamera.setonClickListener( new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                requestPermission();                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);                intent.addcategory(Intent.category_DEFAulT);                startActivityForResult(intent, OPENCAMERA);            }        } );        tophoto.setonClickListener( new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                //打开相册                opengallery();            }        } );    }    /***************Popupwindows在底部显示************/    public  voID ShowPopupwindowsFromButtom(){        popupWindow.showAtLocation( vIEw, Gravity.BottOM,0,0 );    }    /*****************监听返回键*/    @OverrIDe    public boolean onKeyDown(int keyCode, KeyEvent event) {        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK){            if (popupWindow != null && popupWindow.isShowing()){                popupWindow.dismiss();                return true;            }        }        return false;    }    @OverrIDe    protected voID onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {        super.onActivityResult( requestCode, resultCode, data );        //判断是否返回数据        if (resultCode == RESulT_OK) {            //判断返回的类型是否是我们所需            if (requestCode == OPENgalLERY) {                String state = Environment.getExternalStorageState();                if (!state.equals( Environment.MEDIA_MOUNTED ))                    return;                Tiny.fileCompressOptions options = new Tiny.fileCompressOptions();                Tiny.getInstance().source( fileManager.readpic() ).asfile().withOptions( options ).compress( new fileWithBitmapCallback() {                    @OverrIDe                    public voID callback(boolean isSuccess, Bitmap bitmap, String outfile, Throwable t) {                        //sendCropImage(outfile);                    }                } );            } else if (requestCode == OPENCAMERA && resultCode == Activity.RESulT_OK && null != data) {                Bundle bundle = data.getExtras();                Bitmap bitmap = (Bitmap) bundle.get("data");                Image.setimageBitmap(bitmap);            }        }    }    /*****************滑动页的初始化**********************/    private voID InitNavigationVIEw() {        VIEw vIEw = InfarmationManage.getheaderVIEw( 0 );         Image = vIEw.findVIEwByID( R.ID. headImage);         ID = vIEw.findVIEwByID( R.ID.information_Username );        /*如果登陆成功,则把注册的信息从数据库取出*/        Thread thread = new Thread( ()->{            runOnUiThread( ()->{                    try {                        Thread.sleep( 2000 );                    } catch (InterruptedException e) {                        e.printstacktrace();                    }                    if (Login.JudgeLoginStatic == true) {                        ID.setText( Login.Login_Account );                        IntentLoginInterface.setText( "已登陆" );                        LoginTextStatus.setText("已登陆“布道者”智能停车,祝您生活愉快");                    } else {                        ID.setText( "暂未登陆" );                    }            } );        } );        thread.start();        Image.setonClickListener( new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                ShowPopupwindowsFromButtom();            }        } );        /****************滑动页中Menu中的子控件***************/        InfarmationManage.setNavigationItemSelectedListener( new NavigationVIEw.OnNavigationItemSelectedListener() {            Intent intent = null;            @OverrIDe            public boolean onNavigationItemSelected(@NonNull MenuItem item) {                switch (item.getItemID()){                    case R.ID.Personal:                        intent = new Intent( Function.this,Settinginformation.class );                        startActivity( intent );                        break;                    case R.ID.Pay:                        Toast.makeText( Function.this,"1",Toast.LENGTH_SHORT ).show();                        break;                    case R.ID.Car:                        Toast.makeText( Function.this,"2",Toast.LENGTH_SHORT ).show();                        break;                    case R.ID.Collection:                       startActivity( new Intent( Function.this, ParkingType.class ) );                        break;                    case R.ID.file:                       startActivity( new Intent( Function.this, Booking.class ) );                        break;                    case R.ID.Setting:                        Toast.makeText( Function.this,"5",Toast.LENGTH_SHORT ).show();                        break;                    case R.ID.Version:                        Toast.makeText( Function.this,"6",Toast.LENGTH_SHORT ).show();                        break;                        /**订单管理模块*/                    case R.ID.OrderManagement:                        startActivity( new Intent( Function.this, OrderInterface.class ) );                        break;                }                return true;            }        } );    }    /**登陆后改变主页面相应布局*///    private voID UpdateLayout(){//        if (Login.JudgeLoginStatic == true){//            IntentLoginInterface.setText( "已登陆" );//            LoginTextStatus.setText( "已登陆“布道者”智能停车,祝您生活愉快" );//        }//    }   /**初始化RecyclerVIEw数据*/    private voID InitData() {        for (int i = 0; i <7 ; i++) {            ParkingTools tools = null;            String BigPlace = StringBigPlace[i];            String SmallPlace = StringSmallPlace[i];            String distance = Stringdistance[i];            int Icon = IntIcons[i];            tools = new ParkingTools( BigPlace,SmallPlace,Icon,distance );            List.add( tools );        }    }    /**初始化RecyclerVIEw数据*/    private voID InitHorizontalData() {        for (int i = 0; i <6 ; i++) {            MyRecyclerVIEwHorizontal tools = null;            String StringBigTitle = BigTitle[i];            String StringSmallTitle = SmallTitle[i];            int IntBigImage = BigImage[i];            int IntSmallimage = Smallimage[i];            tools = new MyRecyclerVIEwHorizontal( StringBigTitle,StringSmallTitle,IntBigImage,IntSmallimage );            horizontallist.add( tools );        }    }    private voID InitHorizontalAdapter(){        linearlayoutmanager manager = new linearlayoutmanager( getApplicationContext(),RecyclerVIEw.HORIZONTAL,false );        HorizontalRecyclerVIEw.setLayoutManager( manager );        HorizontalAdapter = new RecyclerVIEwHorizontalAdapter( horizontallist );        HorizontalRecyclerVIEw.setAdapter( HorizontalAdapter );    }    /***************RecyclerVIEw适配器初始化*********************/    private voID InitAdapter() {        linearlayoutmanager manager = new linearlayoutmanager( getApplicationContext() );        MyRecyclerVIEw.setLayoutManager( manager );        addpter = new MyRecyclerVIEwTools( List );        MyRecyclerVIEw.setAdapter( addpter );        addpter.setonclick( new MyRecyclerVIEwTools.OnClick() {            String EndAddress = "";            @OverrIDe            public voID OnClickListener(VIEw vIEw, int position) {                if (position == 0){                    EndAddress = "工人文化宫停车场";                }else if (position == 1){                    EndAddress = "停车场(康复路)";                }else if (position == 2){                    EndAddress = "停车场(水木兰庭东南)";                }else if (position == 3){                    EndAddress =    "圣华名城停车场";                }else if (position == 4){                    EndAddress =    "嵘兴.圣华名城停车场";                }else if (position == 5){                    EndAddress =   "中车停车场";                }else if (position == 6){                    EndAddress =   "停车场(杉塘路)";                }                String SpeakContent = "本次导航从当前位置前往"+EndAddress;                if (TTS != null && !TTS.isspeaking()) {                    TTS.setPitch(0.0f);// 设置音调,值越大声音越尖(女生),值越小则变成男声,1.0是常规                    TTS.speak(SpeakContent,TextToSpeech.QUEUE_FLUSH, null);                }else {                    Toast.makeText( Function.this, "语音助手错误", Toast.LENGTH_LONG ).show();                }                if (isBaIDuMAPInstalled()) {                    Navigation(EndAddress);                } else {                    // 未安装                    Toast.makeText( Function.this, "您尚未安装百度地图", Toast.LENGTH_LONG ).show();                }            }        } );    }   /***************初始化界面*********************/    private voID InitVIEw() {        MyRecyclerVIEw = findVIEwByID( R.ID.MyRecyclerVIEw );        HorizontalRecyclerVIEw = findVIEwByID( R.ID.HorizontalRecyclerVIEw );        Search = findVIEwByID( R.ID.Search );        SearchPlace = findVIEwByID( R.ID.SearchPlace );       // UserIcon = findVIEwByID( R.ID.useIcon );        IntentLoginInterface = findVIEwByID( R.ID.IntentLogin );        GoBack = findVIEwByID( R.ID.Function_goback );        Scan = findVIEwByID( R.ID.Scan );        LoginTextStatus = findVIEwByID( R.ID.LoginStatusText );        InfarmationManage = findVIEwByID( R.ID.informationManage );        //LoginStatusSubTiltle = findVIEwByID( R.ID.LoginStatusSubTitle );       // LoginStatusTiltle = findVIEwByID( R.ID.LoginStatusTitle );    }    //执行    private voID requestLocation(){        initLocation();        clIEnt.start();    }    /*******************初始化百度地图各种参数*******************/    private voID initLocation() {        LocationClIEntoption option = new LocationClIEntoption();        option.setLocationMode(LocationClIEntoption.LocationMode.Hight_Accuracy);        /**可选,设置定位模式,默认高精度LocationMode.Hight_Accuracy:高精度;         * LocationMode. Battery_Saving:低功耗;LocationMode. Device_Sensors:仅使用设备;*/        option.setCoorType("bd09ll");        /**可选,设置返回经纬度坐标类型,默认gcj02gcj02:国测局坐标;bd09ll:百度经纬度坐标;bd09:百度墨卡托坐标;         海外地区定位,无需设置坐标类型,统一返回wgs84类型坐标*/        option.setScanSpan(3000);        /**可选,设置发起定位请求的间隔,int类型,单位ms如果设置为0,则代表单次定位,即仅定位一次,默认为0如果设置非0,需设置1000ms以上才有效*/        option.setopenGps(true);        /**可选,设置是否使用gps,默认false使用高精度和仅用设备两种定位模式的,参数必须设置为true*/        option.setLocationNotify(true);        /**可选,设置是否当GPS有效时按照1S/1次频率输出GPS结果,默认false*/        option.setIgnoreKillProcess(false);        /**定位SDK内部是一个service,并放到了独立进程。设置是否在stop的时候杀死这个进程,默认(建议)不杀死,即setIgnoreKillProcess(true)*/        option.SetIgnoreCacheException(false);        /**可选,设置是否收集Crash信息,默认收集,即参数为false*/        option.setIsNeedAltitude(true);/**设置海拔高度*/        option.setWifiCacheTimeOut(5 * 60 * 1000);        /**可选,7.2版本新增能力如果设置了该接口,首次启动定位时,会先判断当前WiFi是否超出有效期,若超出有效期,会先重新扫描WiFi,然后定位*/        option.setEnableSimulateGps(false);        /**可选,设置是否需要过滤GPS仿真结果,默认需要,即参数为false*/        option.setIsNeedAddress(true);        /**可选,设置是否需要地址信息,默认不需要*/        clIEnt.setLocoption(option);        /**mLocationClIEnt为第二步初始化过的LocationClIEnt对象需将配置好的LocationClIEntoption对象,通过setLocoption方法传递给LocationClIEnt对象使用*/    }    /****************监测是否安装了微信***************/    public static boolean CheckWeiXinInstalled(Context context) {        final PackageManager packageManager = context.getPackageManager();// 获取packagemanager        List<PackageInfo> pinfo = packageManager.getInstalledPackages( 0 );// 获取所有已安装程序的包信息        if (pinfo != null) {            for (int i = 0; i < pinfo.size(); i++) {                String pn = pinfo.get( i ).packagename;                if (pn.equals( "com.tencent.mm" )) {                    return true;                }            }        }        return false;    }    /****************监测支付宝是否安装***************/    public static boolean CheckAliPayInstalled(Context context) {        Uri uri = Uri.parse("alipays://platformAPI/startApp");        Intent intent = new Intent(Intent.ACTION_VIEW, uri);        Componentname componentname = intent.resolveActivity(context.getPackageManager());        return componentname != null;    }    /****************跳转到微信扫一扫***************/    private voID toWeiXinScan(Context context){        try {            Intent intent = Function.this.getPackageManager().getLaunchIntentForPackage( "com.tencent.mm" );            intent.putExtra( "LauncherUI.From.Scaner.Shortcut", true );            startActivity( intent );        } catch (Exception e) {            Toast.makeText( Function.this, "没有安装微信", Toast.LENGTH_SHORT ).show();        }    }    /****************跳转到支付宝扫一扫***************/    public static voID toAliPayScan(Context context)    {        try        {            Uri uri = Uri.parse("alipayqr://platformAPI/startapp?saID=10000007");            Intent intent = new Intent(Intent.ACTION_VIEW, uri);            context.startActivity(intent);        } catch (Exception e)        {            Toast.makeText(context, "打开失败,请检查是否安装了支付宝", Toast.LENGTH_SHORT).show();        }    }    //监听事件    private voID Listener(){        OnClick onClick = new OnClick();        //Search.setonClickListener( onClick );        IntentLoginInterface.setonClickListener( onClick );//        UserIcon.setonClickListener( onClick );        GoBack.setonClickListener( onClick );        Scan.setonClickListener( onClick );    }    /****************内部类监听事件***************/    class OnClick implements VIEw.OnClickListener{        Intent intent = null;        TTS tts = null; // 语音助手类        @OverrIDe        public voID onClick(VIEw v) {            switch (v.getID()) {                case R.ID.IntentLogin:                    if (Login.JudgeLoginStatic == false) {                        intent = new Intent( Function.this, Login.class );                    }else{                        IntentLoginInterface.setText( "已登陆" );                        LoginTextStatus.setText("已登陆“布道者”智能停车,祝您生活愉快");                        ID.setText( Login.Login_Account);                        return;                    }                    break;                //跳转到桌面i                case R.ID.Function_goback:                    intent = new Intent( Intent.ACTION_MAIN );                    intent.addcategory( Intent.category_HOME );                    finish();                    break;                case R.ID.Scan:                    if (CheckWeiXinInstalled( Function.this ) == true) {                        toWeiXinScan( Function.this );                    } else if (CheckAliPayInstalled( Function.this ) == true) {                        toAliPayScan( Function.this );                    }                       else {                            Toast.makeText( Function.this, "未安装微信或者支付宝,无法进行支付", Toast.LENGTH_SHORT ).show();                        }                    break;            }            startActivity( intent );        }    }    /****************用于跳转到百度地图***************/    public  voID  Navigation(String EndAddress){        Uri uri = Uri.parse( "baIDumap://map/direction?origin=" + Latitude + "," + Longitude + "&" + "destination=" + EndAddress + "&mode=driving&package=com.baIDu.BaIDuMap;end" );        startActivity( new Intent( Intent.ACTION_VIEW, uri ) );    }    /****************判断百度地图是否安装***************/    public static boolean isBaIDuMAPInstalled(){        return isInstallPackage(BAIDUMAPPACKAGE);    }    private static boolean isInstallPackage(String packagename) {        return new file("/data/data/" + packagename).exists();    }    class MyBaIDuMap implements BDLocationListener{        @OverrIDe        public voID onReceiveLocation(BDLocation bdLocation) {            Latitude = bdLocation.getLatitude();//获取纬度            Longitude = bdLocation.getLongitude();//获取经度            double Radius = bdLocation.geTradius();        }    }    /****************语音助手监听事件***************/    class InitTTS implements TextToSpeech.OnInitListener{        @OverrIDe        public voID onInit(int status) {            if (status == TextToSpeech.SUCCESS) {                int result = TTS.setLanguage( Locale.CHINA);                if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {                    Toast.makeText( Function.this, "数据丢失或不支持", Toast.LENGTH_SHORT).show();                }            }        }    }}
总结

实践出真知

总结

以上是内存溢出为你收集整理的一个简单智能停车APP——主功能界面全部内容,希望文章能够帮你解决一个简单智能停车APP——主功能界面所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1001509.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存