导航:首页 > 操作系统 > androidapi设置

androidapi设置

发布时间:2022-07-02 19:05:35

Ⅰ 如何在安卓应用程序中使用百度api

1)下载网络地图移动版API(android)开发包
要在Android应用中使用网络地图API,就需要在工程中引用网络地图API开发包,这个开发包包含两个文件:mapapi.jar和libBMapApiEngine.so。下载地址:http://dev..com/wiki/static/imap/files/BaiMapApi_Lib_Android_1.0.zip
2)申请API Key
和使用Google map api一样,在使用网络地图API之前也需要获取相应的API Key。网络地图API Key与你的网络账户相关联,因此您必须先有网络帐户,才能获得API Key;并且,该Key与您引用API的程序名称有关。
网络API Key的申请要比Google的简单多了,其实只要你有网络帐号,应该不超过30秒就能完成API Key的申请。申请地址:http://dev..com/wiki/static/imap/key/
3)创建一个Android工程
这里需要强调一点:网络地图移动版api支持Android 1.5及以上系统,因此我们创建的工程应基于Android SDK 1.5及以上。
工程创建完成后,将mapapi.jar和libBMapApiEngine.so分别拷贝到工程的根目录及libs/armeabi目录下,并在工程属性->java Build Path->Libraries中选择“Add JARs”,www.linuxidc.com选定mapapi.jar,这样就可以在应用中使用网络地图API了。工程完整的目录结构如下图所示:

4)在布局文件中添加地图控件(res/layout/main.xml)

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<com..mapapi.MapView android:id="@+id/map_View"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
/>
</LinearLayout>

5)创建Activity继承com..mapapi.MapActivity

package com.liufeng.map;

import android.graphics.drawable.Drawable;
import android.os.Bundle;

import com..mapapi.BMapManager;
import com..mapapi.GeoPoint;
import com..mapapi.MapActivity;
import com..mapapi.MapController;
import com..mapapi.MapView;

public class MainActivity extends MapActivity {
private BMapManager mapManager;
private MapView mapView;
private MapController mapController;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// 初始化MapActivity
mapManager = new BMapManager(getApplication());
// init方法的第一个参数需填入申请的API Key
mapManager.init("", null);
super.initMapActivity(mapManager);

mapView = (MapView) findViewById(R.id.map_View);
// 设置地图模式为交通地图
mapView.setTraffic(true);
// 设置启用内置的缩放控件
mapView.setBuiltInZoomControls(true);

// 用给定的经纬度构造一个GeoPoint(纬度,经度)
GeoPoint point = new GeoPoint((int) (47.118440 * 1E6), (int) (87.493147 * 1E6));

// 创建标记maker
Drawable marker = this.getResources().getDrawable(R.drawable.iconmarka);
// 为maker定义位置和边界
marker.setBounds(0, 0, marker.getIntrinsicWidth(), marker.getIntrinsicHeight());

// 取得地图控制器对象,用于控制MapView
mapController = mapView.getController();
// 设置地图的中心
mapController.setCenter(point);
// 设置地图默认的缩放级别
mapController.setZoom(12);
}

@Override
protected boolean isRouteDisplayed() {
return false;
}

@Override
protected void onDestroy() {
if (mapManager != null) {
mapManager.destroy();
mapManager = null;
}
super.onDestroy();
}

@Override
protected void onPause() {
if (mapManager != null) {
mapManager.stop();
}
super.onPause();
}

@Override
protected void onResume() {
if (mapManager != null) {
mapManager.start();
}
super.onResume();
}
}

Ⅱ ANDROID如何自定义API

在linux下编译android源码,把你的自定义java文件放到framework/core/java/android/的目录的子目录下。make update-api 就行了

Ⅲ android 2.2 api设置edittext光标颜色

android:textCursorDrawable="@null"
android:textCursorDrawable 这个属性是用来控制光标颜色的,

Ⅳ 如何在android程序中使用百度api接口

网络地图、网络语音、网络导航、网络定位等等。
以下为使用网络天气提供的api,具有天气查询,城市设置,短信分享天气等基本功能,界面清爽,不过现在因为网络key的原因失效了,不能更新天气了。.java中的AK替换成自己申请的网络API KEY,申请地址http://lbsyun..com/apiconsole/key。代码有比较详细的注释。代码量也不大,有兴趣的朋友可以自己排查一下。项目编码UTF-8 默认编译版本4.2.2
Android应用源码使用网络天气的爱天气项目源码 Android应用源码使用网络天气的爱天气项目源码 Android应用源码使用网络天气的爱天气项目源码

文件夹 PATH 列表
卷序列号为 767E7528 000A:8F50
E:.
│ 070705 (1).png
│ 070705 (2).png
│ 070705 (3).png
│ javaapk.com文件列表生成工具.bat
│ 更多源码打包下载.url
│ 本源码使用帮助.txt
│ 目录列表.txt

└─iWeather
│ .classpath
│ .project
│ AndroidManifest.xml
│ ic_launcher-web.png
│ proguard-project.txt
│ project.properties

├─.settings
│ org.eclipse.core.resources.prefs
│ org.eclipse.jdt.core.prefs

├─assets
│ └─fonts
│ fangzhenglantingxianhe_GBK.ttf
│ HelveticaNeueLTPro-Lt.ttf


├─gen
│ └─e
│ └─swust
│ └─iweather
│ BuildConfig.java
│ R.java

├─libs
│ │ locSDK_4.0.jar
│ │ wae-for-debug.jar
│ │
│ └─armeabi
│ liblocSDK4.so

├─res
│ ├─drawable
│ │ city_pressed_effect.xml
│ │ title_bar_image_pressed_effect.xml
│ │
│ ├─drawable-hdpi
│ │ bg_cloudy_day.jpg
│ │ bg_cloudy_night.jpg
│ │ bg_fine_day.jpg
│ │ bg_fine_night.jpg
│ │ bg_fog.jpg
│ │ bg_haze.jpg
│ │ bg_na.jpg
│ │ bg_overcast.jpg
│ │ bg_rain.jpg
│ │ bg_sand_storm.jpg
│ │ bg_snow.jpg
│ │ bg_thunder_storm.jpg
│ │ city_bg_pressed.9.png
│ │ drag_view_handle.png
│ │ icon.png
│ │ icon_search.png
│ │ ic_launcher.png
│ │ locate_indicator.png
│ │ search_input_bg.9.png
│ │ select_city_bg_cover.9.png
│ │ select_city_bg_default.jpg
│ │ temperature_small_img.png
│ │ title_bar_about.png
│ │ title_bar_back.png
│ │ title_bar_bg.9.png
│ │ title_bar_refresh.png
│ │ title_bar_shared.png
│ │ today_weather_extra_arrow.png
│ │ trend_bg_line.png
│ │ weather_forcast_bg.9.png
│ │ weather_forecast_icon.png
│ │ weather_icon_cloudy.png
│ │ weather_icon_fine.png
│ │ weather_icon_fog.png
│ │ weather_icon_hail.png
│ │ weather_icon_overcast.png
│ │ weather_icon_rain_big.png
│ │ weather_icon_rain_middle.png
│ │ weather_icon_rain_small.png
│ │ weather_icon_rain_snow.png
│ │ weather_icon_rain_storm.png
│ │ weather_icon_sand_storm.png
│ │ weather_icon_sleet.png
│ │ weather_icon_snow_big.png
│ │ weather_icon_snow_middle.png
│ │ weather_icon_snow_small.png
│ │ weather_icon_snow_storm.png
│ │ weather_icon_thunder_storm.png
│ │ weather_img_cloudy_day.png
│ │ weather_img_cloudy_night.png
│ │ weather_img_fine_day.png
│ │ weather_img_fine_night.png
│ │ weather_img_fog.png
│ │ weather_img_hail.png
│ │ weather_img_overcast.png
│ │ weather_img_rain_big.png
│ │ weather_img_rain_middle.png
│ │ weather_img_rain_small.png
│ │ weather_img_rain_snow.png
│ │ weather_img_rain_storm.png
│ │ weather_img_sand_storm.png
│ │ weather_img_sleet.png
│ │ weather_img_snow_big.png
│ │ weather_img_snow_middle.png
│ │ weather_img_snow_small.png
│ │ weather_img_snow_storm.png
│ │ weather_img_thunder_storm.png
│ │ welcome_bg.jpg
│ │ welcome_icon.png
│ │ wind_samll_img.png
│ │
│ ├─drawable-ldpi
│ │ icon.png
│ │
│ ├─drawable-mdpi
│ │ icon.png
│ │ ic_launcher.png
│ │
│ ├─drawable-xhdpi
│ │ icon.png
│ │ ic_launcher.png
│ │
│ ├─drawable-xxhdpi
│ │ icon.png
│ │
│ ├─layout
│ │ city_item.xml
│ │ select_city.xml
│ │ weather.xml
│ │ weather_dialog.xml
│ │ weather_forecast_item.xml
│ │ welcome.xml
│ │
│ └─values
│ colors.xml
│ dimens.xml
│ strings.xml
│ styles.xml

└─src
└─e
└─swust
└─iweather
│ SelectCity.java
│ Weather.java
│ Welcome.java

├─util
│ Utils.java

└─web
SinaWeather.java
UpdateWeather.java

Ⅳ android 的API如何使用

看来你还连门都没入啊,用的java语言,如何调用api跟java一样的。

还有想使用控件前,必须先找到他的id。
比如:AutoCompleteTextView autocomplete = (AutoCompleteTextView) findViewById(R.id.autocomplete);
想要使用就直接调用方法就可以了:
autocomplete.settext("aaa");

注意直接findViewById只能找本activity设置的布局文件中的控件,如果想要找其他的需要先找到布局文件再去找控件。

Ⅵ 在android中怎么写百度api根据指定位置定位

网络地图SDK为开发者们提供了如下类型的地图覆盖物:


我的位置图层(MyLocationOverlay):用于显示用户当前位置的图层(支持自定义位置图标);


Poi搜索结果图层(PoiOverlay):用于显示兴趣点搜索结果的图层;


路线图层(RouteOverlay):公交、步行和驾车线路图层,将公交、步行和驾车出行方案的路线及关键点显示在地图上(起、终点图标用户可自定义);


公交换乘图层(TransitOverlay):公交换乘线路图层,将某一特定地区的公交出行方案的路线及换乘位置显示在地图上(起、终点图标用户可自定义);


自定义图层(ItemizedOverlay):可将一个或多个兴趣点绘制到地图上,且支持自定义图标(支持动态更新Item位置、图标);


弹出窗图层(PopupOverlay):在地图上显示一个弹出窗口;


几何图形绘制图层(GraphicsOverlay):用于绘制点、折线段、弧线、圆、矩形、多边形等几何图形的图层;


文字绘制图层(TextOverlay):用于绘制文字的图层。


图片图层(GroundOverlay):用于展示用户传入图片的图层。


全景图图层(PanoramaOverlay):在全景图内标绘兴趣点,支持自定义图标样式。


注:除弹出窗图层外,其他各个图层均已实现多实例。全景图图层是针对全景图所使用的特殊图层。


MapView使用一个List管理覆盖物,通过向MapView.getOverlays() add或remove上述类或其基类的实例即可向地图添加或删除覆盖物。在更新地图覆盖物后,需调用MapView.refresh() 使更新生效。




定位原理


使用网络Android定位SDK必须注册GPS和网络使用权限。定位SDK采用GPS、基站、Wi-Fi信号进行定位。当应用程序向定位SDK发起定位请求时,定位SDK会根据应用的定位因素(GPS、基站、Wi-Fi信号)的实际情况(如是否开启GPS、是否连接网络、是否有信号等)来生成相应定位依据进行定位。

用户可以设置满足自身需求的定位依据:

若用户设置GPS优先,则优先使用GPS进行定位,如果GPS定位未打开或者没有可用位置信息,且网络连接正常,定位SDK则会返回网络定位(即Wi-Fi与基站)的最优结果。为了使获得的网络定位结果更加精确,请打开手机的Wi-Fi开关。


下面我们将利用 MyLocationOverlay和 PopupOverlay 这两个类

一 . 导入库文件


在使用网络定位SDKv4.0之前,我们要下载最新的库文件,下载地址:点击下载相关库文件,将liblocSDK4.so文件拷贝到libs/armeabi目录下。将locSDK4.0.jar文件拷贝到工程的libs目录下

LocationClient 定位SDK的核心类,LocationClient类必须在主线程中声明。需要Context类型的参数。Context需要时全进程有效的context,推荐用getApplicationConext获取全进程有效的context,我们调用registerLocationListener(BDLocationListener)方法来注册定位监听接口,BDLocationListener里面有两个方法,onReceiveLocation()(接收异步返回的定位结果),onReceivePoi()(接收异步返回的POI查询结果,POI是“Point of Interest”的缩写,可以翻译成“信息点”,每个POI包含四方面信息,名称、类别、经度、纬度、附近的酒店、饭店,商铺等信息。我们可以叫它为“导航地图信息”,导航地图数据是整个导航产业的基石),我们这里只需要重写onReceiveLocation就行了BDLocation 封装了定位SDK的定位结果,在BDLocationListener的onReceive方法中获取。通过该类用户可以获取error code,位置的坐标,精度半径,地址等信息,对于其getLocType ()方法获取的error code一些情况

61 : GPS定位结果62 : 扫描整合定位依据失败。此时定位结果无效。63 : 网络异常,没有成功向服务器发起请求。此时定位结果无效。65 : 定位缓存的结果。66 : 离线定位结果。通过requestOfflineLocaiton调用时对应的返回结果67 : 离线定位失败。通过requestOfflineLocaiton调用时对应的返回结果68 : 网络连接失败时,查找本地离线定位时对应的返回结果161: 表示网络定位结果162~167: 服务端定位失败

LocationClientOption 用来设置定位SDK的定位方式,比如设置打开GPS,设置是否需要地址信息,设置发起定位请求的间隔时间等等,参数设置完后调用LocationClient 的setLocOption方法LocationOverlay MyLocationOverlay的子类,重写里面的dispatchTap()方法,显示弹出窗口图层PopupOverlay,调用mMapView.getOverlays().add(myLocationOverlay)就将我的位置图层添加到地图里面PopupOverlay 弹出图层,这个类还是比较简单,里面只有三个方法,hidePop() (隐藏弹出图层)showPopup(Bitmap pop, GeoPoint point, int yOffset) (显示弹出图层)和showPopup显示多张图片的重载方法,由于showPopup方法只接受Bitmap对象,所以我们必须将我们的弹出图层View对象转换成Bitmap对象,我们调用getBitmapFromView方法就实现这一转换BDLocationListener接口的onReceiveLocation(BDLocation location) 方法我还要重点讲解下,我们会发现onReceiveLocation方法会反复执行,他执行的间隔跟LocationClientOption类的setScanSpan()方法设定的值有关,我们设定的是5000毫秒,则onReceiveLocation方法每隔5秒执行一次,注意,当我们设定的值大于1000(ms),定位SDK内部使用定时定位模式。调用requestLocation( )后,每隔设定的时间,定位SDK就会进行一次定位。如果定位SDK根据定位依据发现位置没有发生变化,就不会发起网络请求,返回上一次定位的结果;如果发现位置改变,就进行网络请求进行定位,得到新的定位结果。如果你只需要定位一次的话,这个设置小于1000,或者不用设置就可以了,定时定位时,调用一次requestLocation,会定时监听到定位结果 四 . 在运行程序之前,我们还必须在AndroidManifest.xml进行相关配置和权限的声明


还有很重要的一点就是在AndroidManifest.xml中添加下面的内容



android:name=com..location.f

android:enabled=true

android:process=:remote >


android:name=com..lbsapi.API_KEY

android:value=6KOX4mXHeBRzgriV6OP1T2Hw

/>


其中的meta-data问题:网上这样说,大家记住就得了。。。。


因为单独的定位sdk需要一个key值,而定位sdk的值又不像mapManager中可以直接赋值

所以就需要在注册表单中注册

Ⅶ android studio 怎么设置最小api

升级到0.8.1后,打开设置字体大小页面,你会发现不管是Default还是Darcula,都不允许你改变字体的大小,其实这个是因为这两个模式是Android Studio自带模式,所以不允许你改动,你要改的话要自定义自己的模式。如下图:


选中一个你想要的样式,然后点击Save as,然后在弹出的对话框中输入你自己定义的样式的名称。


然后再把Scheme name选择成你自定义的样式,这个时候就可以改了。

Ⅷ android 使用百度api怎么快速定位

在下载页面下载最新的库文件。将liblocSDK2.4.so文件拷贝到libs/armeabi目录下。将locSDK2.4.jar文件拷贝到工程根目录下,并在工程属性->Java Build Path->Libraries中选择“Add JARs”,选定locSDK2.4.jar,确定后返回。这样您就可以在程序中使用网络定位API了。

设置AndroidManifest.xml
为区分2.3版本service,需要将manifest file中的 intent filter声明为com..location.service_v2.4 在application标签中声明service组件

<service android:name="com..location.f" android:enabled="true" android:process=":remote" android:permission="android.permission.BAIDU_LOCATION_SERVICE"> <intent-filter> <action android:name="com..location.service_v2.4"></action> </intent-filter></service>声明使用权限

<permission android:name="android.permission.BAIDU_LOCATION_SERVICE"></permission><uses-permission android:name="android.permission.BAIDU_LOCATION_SERVICE"></uses-permission><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission><uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission><uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission><uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"></uses-permission><uses-permission android:name="android.permission.READ_LOGS"></uses-permission>import相关类

import com..location.BDLocation;import com..location.BDLocationListener;import com..location.LocationClient;import com..location.LocationClientOption;import com..location.BDNotifyListener;//假如用到位置提醒功能,需要import该类功能类的使用
初始化LocationClient类
此处需要注意:LocationClient类必须在主线程中声明。需要Context类型的参数。

public LocationClient mLocationClient = null;public BDLocationListener myListener = new MyLocationListener(); public void onCreate() { mLocationClient = new LocationClient(this); //声明LocationClient类 mLocationClient.registerLocationListener( myListener ); //注册监听函数}实现BDLocationListener接口
BDLocationListener接口有2个方法需要实现:
1.接收异步返回的定位结果,参数是BDLocation类型参数。
2.接收异步返回的POI查询结果,参数是BDLocation类型参数。

public class MyLocationListenner implements BDLocationListener { @Override public void onReceiveLocation(BDLocation location) { if (location == null) return ; StringBuffer sb = new StringBuffer(256); sb.append("time : "); sb.append(location.getTime()); sb.append("\nerror code : "); sb.append(location.getLocType()); sb.append("\nlatitude : "); sb.append(location.getLatitude()); sb.append("\nlontitude : "); sb.append(location.getLongitude()); sb.append("\nradius : "); sb.append(location.getRadius()); if (location.getLocType() == BDLocation.TypeGpsLocation){ sb.append("\nspeed : "); sb.append(location.getSpeed()); sb.append("\nsatellite : "); sb.append(location.getSatelliteNumber()); } else if (location.getLocType() == BDLocation.TypeNetWorkLocation){ sb.append("\naddr : "); sb.append(location.getAddrStr()); } logMsg(sb.toString()); }public void onReceivePoi(BDLocation poiLocation) { if (poiLocation == null){ return ; } StringBuffer sb = new StringBuffer(256); sb.append("Poi time : "); sb.append(poiLocation.getTime()); sb.append("\nerror code : "); sb.append(poiLocation.getLocType()); sb.append("\nlatitude : "); sb.append(poiLocation.getLatitude()); sb.append("\nlontitude : "); sb.append(poiLocation.getLongitude()); sb.append("\nradius : "); sb.append(poiLocation.getRadius()); if (poiLocation.getLocType() == BDLocation.TypeNetWorkLocation){ sb.append("\naddr : "); sb.append(poiLocation.getAddrStr()); } if(poiLocation.hasPoi()){ sb.append("\nPoi:"); sb.append(poiLocation.getPoi()); }else{ sb.append("noPoi information"); } logMsg(sb.toString()); }}设置参数
设置定位参数包括:定位模式(单次定位,定时定位),返回坐标类型,是否打开GPS等等。eg:

LocationClientOption option = new LocationClientOption();option.setOpenGps(true);option.setAddrType("detail");option.setCoorType("gcj02");option.setScanSpan(5000);option.disableCache(true);//禁止启用缓存定位option.setPoiNumber(5); //最多返回POI个数 option.setPoiDistance(1000); //poi查询距离 option.setPoiExtraInfo(true); //是否需要POI的电话和地址等详细信息 mLocClient.setLocOption(option);发起定位请求
发起定位请求。请求过程是异步的,定位结果在上面的监听函数onReceiveLocation中获取。

if (mLocClient != null && mLocClient.isStarted()) mLocClient.requestLocation();else Log.d("LocSDK_2.0_Demo1", "locClient is null or not started");发起POI查询请求
发起POI查询请求。请求过程是异步的,定位结果在上面的监听函数onReceivePoi中获取。

if (mLocClient != null && mLocClient.isStarted()) mLocClient.requestPoi();位置提醒使用
位置提醒最多提醒3次,3次过后将不再提醒。 假如需要再次提醒,或者要修改提醒点坐标,都可通过函数SetNotifyLocation()来实现。

//位置提醒相关代码mNotifyer = new NotifyLister();mNotifyer.SetNotifyLocation(42.03249652949337,113.3129895882556,3000,"gps");//4个参数代表要位置提醒的点的坐标,具体含义依次为:纬度,经度,距离范围,坐标系类型(gcj02,gps,bd09,bd09ll)mLocationClient.registerNotify(mNotifyer);//注册位置提醒监听事件后,可以通过SetNotifyLocation 来修改位置提醒设置,修改后立刻生效。
//BDNotifyListner实现public class NotifyLister extends BDNotifyListener{ public void onNotify(BDLocation mlocation, float distance){ mVibrator01.vibrate(1000);//振动提醒已到设定位置附近 }}
//取消位置提醒mLocationClient.removeNotifyEvent(mNotifyer);

Ⅸ 安卓手机怎么设置百度地图api缩放比例

设置缩放的方法
mBaiMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().zoom(15).build()));
//设置缩放级别
或者是

float zoomLevel = Float.parseFloat(t.getText().toString());
MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(zoomLevel);
mBaiMap.animateMapStatus(u);

以上是网络的示例程序BaiMapsApiDemo(在网络LBS开放平台-》android SDK有下载)中,MapControlDemo.java中的一段,用来设置地图缩放比例的

阅读全文

与androidapi设置相关的资料

热点内容
单片机如何使用proteus 浏览:991
java常用的服务器 浏览:281
集结APP在哪里下载 浏览:800
欧洲cf玩什么服务器 浏览:529
如何连接另一台电脑上的共享文件夹 浏览:681
如何让桌面文件夹搬家到e盘 浏览:73
java自动格式化 浏览:619
ipad怎么查看文件夹大小 浏览:583
手工粘土解压球 浏览:552
在线视频教育源码 浏览:41
快四十学什么编程 浏览:754
gnumakelinux 浏览:537
视易峰云服务器怎么改系统 浏览:535
javamap取值 浏览:768
mac和win磁盘加密软件 浏览:474
苹果为什么会连接不到服务器 浏览:726
pdf格式文件如何保存 浏览:303
小霸王服务器tx什么意思 浏览:75
解释dns命令 浏览:584
dmx512怎么编程 浏览:744