导航:首页 > 操作系统 > androidged

androidged

发布时间:2022-08-31 12:14:57

A. android是如何使用AndroidManifest.xml的

一、关于AndroidManifest.xml

AndroidManifest.xml 是每个android程序中必须的文件。它位于整个项目的根目录,描述了package中暴露的组件(activities, services, 等等),他们各自的实现类,各种能被处理的数据和启动位置。 除了能声明程序中的Activities, ContentProviders, Services, 和Intent Receivers,还能指定permissions和instrumentation(安全控制和测试)

二、AndroidManifest.xml结构

<?xmlversion="1.0"encoding="utf-8"?>
<manifest>
<application>
<activity>
<intent-filter>
<action/>
<category/>
</intent-filter>
</activity>
<activity-alias>
<intent-filter></intent-filter>
<meta-data/>
</activity-alias>
<service>
<intent-filter></intent-filter>
<meta-data/>
</service>
<receiver>
<intent-filter></intent-filter>
<meta-data/>
</receiver>
<provider>
<grant-uri-permission/>
<meta-data/>
</provider>
<uses-library/>
</application>
<uses-permission/>
<permission/>
<permission-tree/>
<permission-group/>
<instrumentation/>
<uses-sdk/>
<uses-configuration/>
<uses-feature/>
<supports-screens/>
</manifest>

三、各个节点的详细介绍

上面就是整个am(androidManifest).xml的结构,下面以外向内开始阐述~~

1、第一层(<Manifest>):(属性)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.woody.test"
android:sharedUserId="string"
android:sharedUserLabel="string resource"
android:versionCode="integer"
android:versionName="string"
android:installLocation=["auto" | "internalOnly" | "preferExternal"] >
</manifest>

A、xmlns:android

定义android命名空间,一般为http://schemas.android.com/apk/res/android,这样使得Android中各种标准属性能在文件中使用,提供了大部分元素中的数据。


B、package

指定本应用内java主程序包的包名,它也是一个应用进程的默认名称


C、sharedUserId

表明数据权限,因为默认情况下,Android给每个APK分配一个唯一的UserID,所以是默认禁止不同APK访问共享数据的。若要共享数据,第一可以采用Share Preference方法,第二种就可以采用sharedUserId了,将不同APK的sharedUserId都设为一样,则这些APK之间就可以互相共享数据了。详见:http://wallage.blog.163.com/blog/static/17389624201011010539408/

D、sharedUserLabel

一个共享的用户名,它只有在设置了sharedUserId属性的前提下才会有意义


E、versionCode

是给设备程序识别版本(升级)用的必须是一个interger值代表app更新过多少次,比如第一版一般为1,之后若要更新版本就设置为2,3等等。。。


F、versionName

这个名称是给用户看的,你可以将你的APP版本号设置为1.1版,后续更新版本设置为1.2、2.0版本等等。。。


G、installLocation

安装参数,是Android2.2中的一个新特性,installLocation有三个值可以选择:internalOnly、auto、preferExternal

选择preferExternal,系统会优先考虑将APK安装到SD卡上(当然最终用户可以选择为内部ROM存储上,如果SD存储已满,也会安装到内部存储上)

选择auto,系统将会根据存储空间自己去适应

选择internalOnly是指必须安装到内部才能运行

(注:需要进行后台类监控的APP最好安装在内部,而一些较大的游戏APP最好安装在SD卡上。现默认为安装在内部,如果把APP安装在SD卡上,首先得设置你的level为8,并且要配置android:installLocation这个参数的属性为preferExternal)


2、第二层(<Application>):属性

一个AndroidManifest.xml中必须含有一个Application标签,这个标签声明了每一个应用程序的组件及其属性(如icon,label,permission等)

<application android:allowClearUserData=["true" | "false"]
android:allowTaskReparenting=["true" | "false"]
android:backupAgent="string"
android:debuggable=["true" | "false"]
android:description="string resource"
android:enabled=["true" | "false"]
android:hasCode=["true" | "false"]
android:icon="drawable resource"
android:killAfterRestore=["true" | "false"]
android:label="string resource"
android:manageSpaceActivity="string"
android:name="string"
android:permission="string"
android:persistent=["true" | "false"]
android:process="string"
android:restoreAnyVersion=["true" | "false"]
android:taskAffinity="string"
android:theme="resource or theme" >
</application>

A、android:allowClearUserData('true' or 'false')

用户是否能选择自行清除数据,默认为true,程序管理器包含一个选择允许用户清除数据。当为true时,用户可自己清理用户数据,反之亦然


B、android:allowTaskReparenting('true' or 'false')

是否允许activity更换从属的任务,比如从短信息任务切换到浏览器任务


C、android:backupAgent

这也是Android2.2中的一个新特性,设置该APP的备份,属性值应该是一个完整的类名,如com.project.TestCase,此属性并没有默认值,并且类名必须得指定(就是个备份工具,将数据备份到云端的操作)


D、android:debuggable

这个从字面上就可以看出是什么作用的,当设置为true时,表明该APP在手机上可以被调试。默认为false,在false的情况下调试该APP,就会报以下错误:

Device XXX requires that applications explicitely declare themselves as debuggable in their manifest.

Application XXX does not have the attribute 'debuggable' set to TRUE in its manifest and cannot be debugged.


E、android:description/android:label

此两个属性都是为许可提供的,均为字符串资源,当用户去看许可列表(android:label)或者某个许可的详细信息(android:description)时,这些字符串资源就可以显示给用户。label应当尽量简短,之需要告知用户该许可是在保护什么功能就行。而description可以用于具体描述获取该许可的程序可以做哪些事情,实际上让用户可以知道如果他们同意程序获取该权限的话,该程序可以做什么。我们通常用两句话来描述许可,第一句描述该许可,第二句警告用户如果批准该权限会可能有什么不好的事情发生


F、android:enabled

Android系统是否能够实例化该应用程序的组件,如果为true,每个组件的enabled属性决定那个组件是否可以被 enabled。如果为false,它覆盖组件指定的值;所有组件都是disabled。


G、android:hasCode('true' or 'false')

表示此APP是否包含任何的代码,默认为true,若为false,则系统在运行组件时,不会去尝试加载任何的APP代码

一个应用程序自身不会含有任何的代码,除非内置组件类,比如Activity类,此类使用了AliasActivity类,当然这是个罕见的现象

(在Android2.3可以用标准C来开发应用程序,可在androidManifest.xml中将此属性设置为false,因为这个APP本身已经不含有任何的JAVA代码了)

H、android:icon

这个很简单,就是声明整个APP的图标,图片一般都放在drawable文件夹

I、android:killAfterRestore

J、android:manageSpaceActivity

K、android:name

为应用程序所实现的Application子类的全名。当应用程序进程开始时,该类在所有应用程序组件之前被实例化。

若该类(比方androidMain类)是在声明的package下,则可以直接声明android:name="androidMain",但此类是在package下面的子包的话,就必须声明为全路径或android:name="package名称.子包名成.androidMain"

L、android:permission

设置许可名,这个属性若在<application>上定义的话,是一个给应用程序的所有组件设置许可的便捷方式,当然它是被各组件设置的许可名所覆盖的

M、android:presistent

该应用程序是否应该在任何时候都保持运行状态,默认为false。因为应用程序通常不应该设置本标识,持续模式仅仅应该设置给某些系统应用程序才是有意义的。

N、android:process

应用程序运行的进程名,它的默认值为<manifest>元素里设置的包名,当然每个组件都可以通过设置该属性来覆盖默认值。如果你想两个应用程序共用一个进程的话,你可以设置他们的android:process相同,但前提条件是他们共享一个用户ID及被赋予了相同证书的时候

O、android:restoreAnyVersion

同样也是android2.2的一个新特性,用来表明应用是否准备尝试恢复所有的备份,甚至该备份是比当前设备上更要新的版本,默认是false

P、android:taskAffinity

拥有相同的affinity的Activity理论上属于相同的Task,应用程序默认的affinity的名字是<manifest>元素中设定的package名


Q、android:theme

是一个资源的风格,它定义了一个默认的主题风格给所有的activity,当然也可以在自己的theme里面去设置它,有点类似style。



不过现在在android stuido 上面 版本控制已经使用Gradle了。

B. 安卓开发 failed to get ged log buf,err怎么解决

是因为android的插件没有安装,需要安装插件。

操作步骤:

1、点击“settings”选项。


注意事项:

1、Unix/Linux平台技术:基本命令,Linux下的开发环境。

2、企业级数据库技术:SQL语言、SQL语句调优、Oracle数据库技术。

3、Java 语言核心技术:Java语言基础、Java面向对象编程、JDK核心API、Java集合框架、Java网络编 程、JavaI/O编程、Java多线程编程、Java异常机制、Java安全、JDBC、XML。

4、软件工程和设计模式:软件工程概述、配置管理及SVN、UML、基本设计模式。

C. 我用eclipse写的android聊天软件连接不到本地openfire,初始配置都是从网上参考的,就是不行,

填你的电脑的ip,别用127.0.0.1,这个表示Android自己本机

D. android中mqtt怎么做

MQTT连接建立的代码(SSL方式)

[java] view plain
public static void connect(Driver driver) {
ServerConfig serverConfig = UserMole.Instance.getServerConfig();
MqttConnectOptions conOpt = new MqttConnectOptions();
try {
SSLContext sslContext;
KeyStore ts = KeyStore.getInstance("BKS");
ts.load(context.getResources().openRawResource(R.raw.test_cert),
"123456".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("X509");
tmf.init(ts);
TrustManager[] tm = tmf.getTrustManagers();
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, tm, null);

SocketFactory factory = sslContext.getSocketFactory();
conOpt.setSocketFactory(factory);
} catch (Exception e) {
e.printStackTrace();
}
<span style="white-space:pre"> </span>
[java] view plain
<span style="white-space:pre"> </span>//paho库得
Iterator<Map.Entry<String, Connection>> it = Connections
.getInstance(context).getConnections().entrySet().iterator();
while (it.hasNext()) {
MqttClientAndroidService detectClient = it.next().getValue()
.getClient();
try {
detectClient.disconnect();
} catch (MqttException e) {
e.printStackTrace();
}
it.remove();
}

// The basic client information
MqttClientAndroidService client;
client = Connections.getInstance(context).createClient(context,
serverConfig.getUri(), serverConfig.clientId);
Integer qos = Integer.parseInt(context.getResources().getString(
R.string.qos));
Boolean retained = Boolean.parseBoolean(context.getResources()
.getString(R.string.retained));

// connection options
int timeout = Integer.parseInt(context.getResources().getString(
(R.string.timeout)));
int keepalive = Integer.parseInt(context.getResources().getString(
R.string.keepalive));

Connection connection = new Connection(serverConfig.getClientHandle(),
serverConfig.clientId, serverConfig.server,
Integer.parseInt(serverConfig.port), context, client,
serverConfig.ssl);

// connection.registerChangeListener(changeListener);
// connect client

String[] actionArgs = new String[1];
actionArgs[0] = serverConfig.clientId;
connection.changeConnectionStatus(ConnectionStatus.CONNECTING);

boolean cleanSession = false;
conOpt.setCleanSession(cleanSession);
conOpt.setConnectionTimeout(timeout);
conOpt.setKeepAliveInterval(keepalive);
if (!TextUtils.isEmpty(serverConfig.user)) {
conOpt.setUserName(serverConfig.user);
}
if (!TextUtils.isEmpty(serverConfig.pwd)) {
conOpt.setPassword(serverConfig.pwd.toCharArray());
}
// conOpt.setPassword("1111".toCharArray());
final ActionListener callback = new ActionListener(context,
ActionListener.Action.CONNECT, driver.getMqttUtilsCallback(),
serverConfig.getClientHandle(), actionArgs);

boolean doConnect = true;

String message = ActivityConstants.message;
String topic = ActivityConstants.topic;

if ((!TextUtils.isEmpty(message) || !TextUtils.isEmpty(topic))) {
// need to make a message since last will is set
try {
conOpt.setWill(topic, message.getBytes(), qos.intValue(),
retained.booleanValue());
} catch (Exception e) {
e.printStackTrace();
doConnect = false;
callback.onFailure(null, e);
}
}
client.setCallback(new MqttCallbackHandler(context, serverConfig
.getClientHandle(), driver));

connection.addConnectionOptions(conOpt);
Connections.getInstance(context).addConnection(connection);
if (doConnect) {
try {
client.connect(conOpt, null, callback);
} catch (MqttException e) {
Log.e(TAG, "MqttException Occured", e);
}
}
}
发布(publish)代码
[java] view plain
public static void publish(String clientHandle, String topic,
JSONObject jsonObj, int qos) {
MqttClientAndroidService client = Connections.getInstance(context)
.getConnection(clientHandle).getClient();
if (!isConnected(context)) {
try {
client.connect();
} catch (MqttException e) {
e.printStackTrace();
}
Toast.makeText(context, "please try again", Toast.LENGTH_SHORT)
.show();
return;
}
if (topic == null) {
Toast.makeText(context, "can not get other's identity for now",
Toast.LENGTH_SHORT).show();
return;
}
String[] args = new String[2];
if (jsonObj.optLong("time") != 0) {
args[0] = String.valueOf(jsonObj.optLong("time"));
args[1] = topic;
}

Boolean retained = Boolean.parseBoolean(context.getResources()
.getString(R.string.retained));
try {
client.publish(topic, jsonObj.toString().getBytes(), qos, retained,
null, new ActionListener(context, Action.PUBLISH, null,
clientHandle, args));
} catch (MqttSecurityException e) {
Log.e(TAG,
"Failed to publish a messged from the client with the handle "
+ clientHandle, e);
} catch (MqttException e) {
Log.e(TAG,
"Failed to publish a messged from the client with the handle "
+ clientHandle, e);
}
}
订阅(subscribe)代码
[java] view plain
public static void subscribe(MqttUtilsCallback mqttUtilsCallback,
String clientHandle, String topic) {
MqttClientAndroidService client = Connections.getInstance(context)
.getConnection(clientHandle).getClient();
if (client == null || (client != null && !client.isConnected())) {
Toast.makeText(context, "please connect to server first",
Toast.LENGTH_SHORT).show();
return;
}

if (TextUtils.isEmpty(topic)) {
topic = "hello";
}
String[] topics = new String[1];
topics[0] = topic;
try {
client.subscribe(topic, 1, null, new ActionListener(context,
ActionListener.Action.SUBSCRIBE, mqttUtilsCallback,
clientHandle, topics));
} catch (MqttSecurityException e) {
Log.e(TAG, "Failed to subscribe to" + topic
+ " the client with the handle " + clientHandle, e);
} catch (MqttException e) {
Log.e(TAG, "Failed to subscribe to" + topic
+ " the client with the handle " + clientHandle, e);
}

E. 安卓开发程序已停止 大神呀 求救呀 这是什么问题呀

03-2213:27:05.709:E/AndroidRuntime(9698):java.lang.RuntimeException:{com.example.cehualayout/com.example.cehualayout.MainActivity}:java.lang.ClassNotFoundException:Didn'tfindclass"com.example.cehualayout.MainActivity"onpath:/data/app/com.example.cehualayout-2.apk

F. android google map 开发 定位 不点击myLocationbutton就直接实现定位

你把button的click里的代码写到onCreate里就可以了啊

G. 日常生活中用到的英文缩写

1、WC 厕所

很早以前,厕所Toilet里都有水箱water closet,人们一提到water closet就想到了toilet,因此water closet就成了toilet的代名词。后来为了方便,人们就用water closet的开头字母W.C.来代替toilet。

WC是一种很粗俗的表达方式(相当于中国乡村常在厕所中标“男”“女”),是英美等国一二百年前使用的,现在多使用TOILET、Bathroom、Restroom(AmE)等较文雅的词。

2、VCD 影音光盘

VCD,影音光盘(Video Compact Disc;VCD),是一种在光盘上存储视频信息的标准。VCD可以在个人电脑或VCD播放器以及大部分DVD播放器中播放。VCD标准由索尼、飞利浦、JVC、松下等电器生产厂商联合于1993年[1-2]制定,属于数字光盘的白皮书标准。

3、APEC

亚洲太平洋经济合作组织(Asia-Pacific Economic Cooperation,缩写APEC),简称亚太经合组织,是亚太地区重要的经济合作论坛,也是亚太地区最高级别的政府间经济合作机制。

1989年11月5日至7日,举行亚太经济合作会议首届部长级会议,标志着亚太经济合作组织的成立。1993年6月改名为亚太经济合作组织。1991年11月,中国以主权国家身份,中国台北和中国香港以地区经济体名义正式加入亚太经合组织。

2001年10月,APEC会议在中国上海举办。这是APEC会议首次在中国举行。2014年,APEC会议时隔13年再次来到中国。截至2014年9月,亚太经合组织共有21个正式成员和三个观察员。

4、APP 手机软件

手机软件,主要指安装在智能手机上的软件,完善原始系统的不足与个性化。使手机完善其功能,为用户提供更丰富的使用体验的主要手段。

手机软件的运行需要有相应的手机系统,目前(2017年6月1日)主要的手机系统:1.苹果公司的iOS.2.谷歌公司的Android(安卓)系统。

5、BRT 快速公交系统

快速公交系统(BRT )作为公共交通中的一种方式,它是由快速公交车站、快速公交车、服务、营运方式、智能公交系统(ITS)等元素集成的系统。快速公交系统具有自己鲜明的特色,可以形成城市独特的形象。

简而言之,快速公交系统就是由人员、服务和各项相关措施集约而成的一个可以提升公交运营速度、可靠性和改善公交系统状况的一个综合公交运营体系。

H. android 怎样使自己的网络请求使用虚拟mac地址

不改 回答者:匿名 5-3 12:06 网上有MAC地址的软件,你就在网络里搜搜看看,祝你好运! 回答者:fujj - 助理 二级 5-4 15:20 可以不用改的.不知道你从那里听说要这样改. 呵呵. 虚拟机网络设置有4种模式: 1:Birdged 桥接模式,该模式是相当于把你的虚拟机像一台真实主机一样接到你的网内,和你的主机具有同等地位。而虚拟机内的操作系统上的网卡,也同样有一个虚拟出来的MAC地址,这个MAC地址在真实网络中是真实有效的. 你在选择这种模式的情况下,还需要以下步骤的设置: Edit(编辑)----Virtual Network settings..(修改网络属性)----Host Virtual Network Mapping---VMnet0(注释:把这个网卡设置选择为你的本机的真实网卡) 2:NAT 这种模式是由安装在你真实主机上的虚拟机程序,在你电脑上虚拟出一张名为:VMWare Network Adapter VMnet8 .的网卡,而这张网卡的作用是启动NAT和DHPC服务. 相当于一个智能交换机,可以提供NAT数据转换服务和DHPC服务.NAT服务主要是为你的“虚拟操作系统”和真实主机提供数据交换;DHPC服务是为你的虚拟操作系统提供自动分配IP服务(这里值得注意的是:VMnet8这张网卡的的IP是不能随便修改的)。 从而为你的你虚拟机中安装的的操作系统模拟出一个局域网. 3:Host-only 该模式与NAT相似,它是由虚拟在你真实主机上虚拟出来的网卡:VMWare Network Adapter VMnet1 决定的. VMnet1这张网卡同样会提供DHPC服务为你的虚拟操作系统分配IP. 但是这种模式下的操作系统只能与你的真实主机通信,而不能联上你家的internet.(这里我给你解释一下,通常人们喜欢把真实主机称为:虚拟机的“宿主”,呵呵) 所以,你在家想让虚拟操作系统上网别选择这个模式. 4:自定义模式. 这种模式一般是在单机上试验复杂的网络结构而设定的. 我就不给你作详细解释了. 综上所述: (1):你在家里上网可以采用第1,第2;两种模式.如果你使用ADSL方式我建议你使用“桥接”模式. 这样更方便. 使用桥接模式可以把VMnet1和VMnet8这两张网卡禁用.以免对你的虚拟操作系统产生影响. (2):我本人想强调几点: 首先“虚拟机”与“虚拟操作系统”不能混淆; “虚拟机”指的是在你真实主机内安装的“虚拟机程序” “虚拟操作系统”指的是你的“虚拟机内安装的操作系统” 网上很多人对这个概念十分模糊,甚至有人认为:虚拟机在你真实主机上的网卡就是虚拟操作系统里的网卡. 这种想法是完全错误的. 其次,不要认为你在虚拟机上为所欲为都不会影响你的真实主机.因为在虚拟机内的操作,都会用到你的真实物理硬件:如物理内存,硬盘等. 如果你操作不正确,或频繁的在虚拟机内安装操作系统,同样也会在你真实主机上留下很多磁盘碎片.所以操作虚拟机同样也应该按正确的步骤进行. 最后,这篇文档完全是现在手工打字,绝对不是在网上复制的,所以你可以考虑再给我追加20分.我说得很多,是因为想让很多人都不必为这种简单的问题所困扰.

I. android中遇到failed to get ged怎么解决

failed to get的意思是未能获得,看路径是否添加正确,如果不正确肯定是没有获取到的。

J. Android怎么实现点击按钮获取当前位置的信息,没有地图的情况下。

1、首先,检查那个供应商是有效的。有些在设备上可能没效,有些可能在应用程序清单中无效。
2、如果有有效的供应商,启动位置监听和路由失效定时器。
3、如果从位置监听器获得更新,用供应的值,停止监听器和定时器。
4、如果没有获得更新,并且时间已经结束,那就用最后一个已知值。
5、从有效供应商获取最后一个已知值并且选择最接近的。
class MyLocation{

/**
* If GPS is enabled.
* Use minimal connected satellites count.
*/
private static final int min_gps_sat_count = 5;

/**
* Iteration step time.
*/
private static final int iteration_timeout_step = 500;

LocationResult locationResult;
private Location bestLocation = null;
private Handler handler = new Handler();
private LocationManager myLocationManager;
public Context context;

private boolean gps_enabled = false;

private int counts = 0;
private int sat_count = 0;

private Runnable showTime = new Runnable() {

public void run() {
boolean stop = false;
counts++;
System.println("counts=" + counts);

//if timeout (1 min) exceeded, stop tying
if(counts > 120){
stop = true;
}

//update last best location
bestLocation = getLocation(context);

//if location is not ready or don`t exists, try again
if(bestLocation == null && gps_enabled){
System.println("BestLocation not ready, continue to wait");
handler.postDelayed(this, iteration_timeout_step);
}else{
//if best location is known, calculate if we need to continue to look for better location
//if gps is enabled and min satellites count has not been connected or min check count is smaller then 4 (2 sec)
if(stop == false && !needToStop()){
System.println("Connected " + sat_count + " sattelites. continue waiting..");
handler.postDelayed(this, iteration_timeout_step);
}else{
System.println("#########################################");
System.println("BestLocation finded return result to main. sat_count=" + sat_count);
System.println("#########################################");

// removing all updates and listeners
myLocationManager.removeUpdates(gpsLocationListener);
myLocationManager.removeUpdates(networkLocationListener);
myLocationManager.removeGpsStatusListener(gpsStatusListener);
sat_count = 0;

// send best location to locationResult
locationResult.gotLocation(bestLocation);
}
}
}
};

/**
* Determine if continue to try to find best location
*/
private Boolean needToStop(){

if(!gps_enabled){
return true;
}
else if(counts <= 4){
return false;
}
if(sat_count < min_gps_sat_count){
//if 20-25 sec and 3 satellites found then stop
if(counts >= 40 && sat_count >= 3){
return true;
}
return false;
}
}
return true;
}

/**
* Best location abstract result class
*/
public static abstract class LocationResult{
public abstract void gotLocation(Location location);
}

/**
* Initialize starting values and starting best location listeners
*
* @param Context ctx
* @param LocationResult result
*/
public void init(Context ctx, LocationResult result){
context = ctx;
locationResult = result;

myLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

gps_enabled = (Boolean) myLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

bestLocation = null;
counts = 0;

// turning on location updates
myLocationManager.requestLocationUpdates("network", 0, 0, networkLocationListener);
myLocationManager.requestLocationUpdates("gps", 0, 0, gpsLocationListener);
myLocationManager.addGpsStatusListener(gpsStatusListener);

// starting best location finder loop
handler.postDelayed(showTime, iteration_timeout_step);
}

/**
* GpsStatus listener. OnChainged counts connected satellites count.
*/
public final GpsStatus.Listener gpsStatusListener = new GpsStatus.Listener() {
public void onGpsStatusChanged(int event) {

if(event == GpsStatus.GPS_EVENT_SATELLITE_STATUS){
try {
// Check number of satellites in list to determine fix state
GpsStatus status = myLocationManager.getGpsStatus(null);
Iterable<GpsSatellite>satellites = status.getSatellites();

sat_count = 0;

Iterator<GpsSatellite>satI = satellites.iterator();
while(satI.hasNext()) {
GpsSatellite satellite = satI.next();
System.println("Satellite: snr=" + satellite.getSnr() + ", elevation=" + satellite.getElevation());
sat_count++;
}
} catch (Exception e) {
e.printStackTrace();
sat_count = min_gps_sat_count + 1;
}

System.println("#### sat_count = " + sat_count);
}
}
};

/**
* Gps location listener.
*/
public final LocationListener gpsLocationListener = new LocationListener(){
@Override
public void onLocationChanged(Location location){

}
public void onProviderDisabled(String provider){}
public void onProviderEnabled(String provider){}
public void onStatusChanged(String provider, int status, Bundle extras){}
};

/**
* Network location listener.
*/
public final LocationListener networkLocationListener = new LocationListener(){
@Override
public void onLocationChanged(Location location){

}
public void onProviderDisabled(String provider){}
public void onProviderEnabled(String provider){}
public void onStatusChanged(String provider, int status, Bundle extras){}
};

/**
* Returns best location using LocationManager.getBestProvider()
*
* @param context
* @return Location|null
*/
public static Location getLocation(Context context){
System.println("getLocation()");

// fetch last known location and update it
try {
LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
criteria.setAltitudeRequired(false);
criteria.setBearingRequired(false);
criteria.setCostAllowed(true);
String strLocationProvider = lm.getBestProvider(criteria, true);

System.println("strLocationProvider=" + strLocationProvider);
Location location = lm.getLastKnownLocation(strLocationProvider);
if(location != null){
return location;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

阅读全文

与androidged相关的资料

热点内容
程序员可以干什么 浏览:70
绩效考核权重分配算法 浏览:524
android应用logo 浏览:898
光遇安卓服墓土商店什么时候开 浏览:566
月收益翻倍的源码 浏览:636
asop源码放在哪里 浏览:988
电脑服务器密码怎么找 浏览:574
jdp转换pdf 浏览:749
把pdf导入iphone 浏览:508
米哈游租赁的云服务器是哪个 浏览:524
android直接打电话 浏览:1016
ubuntu停止命令 浏览:283
cnc攻丝编程 浏览:869
换个手机号码app怎么注册 浏览:320
怎么下载小猴口算app 浏览:115
轻链app的货怎么样 浏览:625
电脑里的u盘如何加密 浏览:370
我的世界全部版本服务器下载地址 浏览:50
交换原理pdf 浏览:229
菜鸟驿站app怎么邀请新人 浏览:448