package cn.etzmico.gpsswitch;
import android.app.Activity;
import android.app.PendingIntent;
import android.app.PendingIntent.CanceledException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
public class Etzmico_GPSSwitchActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//GPS开关代码
Intent GPSIntent = new Intent();
GPSIntent.setClassName("com.android.settings",
"com.android.settings.widget.SettingsAppWidgetProvider");
GPSIntent.addCategory("android.intent.category.ALTERNATIVE");
GPSIntent.setData(Uri.parse("custom:3"));
try {
PendingIntent.getBroadcast(this, 0, GPSIntent, 0).send();
} catch (CanceledException e) {
e.printStackTrace();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【Android】代码开启/关闭GPSDemo 相关文章:http://blog.csdn.net/etzmico/article/details/7200470 为了方便看效果,您可以在在onCreate中添加finish();方法,然后打开系统GPS设置页面再运行代码,这样就能看到GPS开关的变化了。
资源推荐
资源详情
资源评论
收起资源包目录
Etzmico_GPS开关.zip (19个子文件)
Etzmico_GPSSwitch
bin
classes.dex 3KB
Etzmico_GPSSwitch.apk 9KB
classes
cn
etzmico
gpsswitch
R$layout.class 400B
R$drawable.class 406B
R$attr.class 346B
R.class 501B
Etzmico_GPSSwitchActivity.class 2KB
R$string.class 433B
resources.ap_ 6KB
res
drawable
icon.png 4KB
values
strings.xml 178B
layout
main.xml 398B
gen
cn
etzmico
gpsswitch
R.java 642B
proguard.cfg 1KB
src
cn
etzmico
gpsswitch
Etzmico_GPSSwitchActivity.java 880B
.project 853B
.classpath 364B
project.properties 360B
AndroidManifest.xml 743B
共 19 条
- 1
伊茨米可
- 粉丝: 128
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页