/**
* @version: 1.0.0
*/
package com.apns.demo;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import com.apns.APNService;
public class APNSDemo extends Activity {
private String devId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
// 获取设备Id
devId = "null";
TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null)
devId = telephonyManager.getDeviceId();
TextView devIdView = (TextView)findViewById(R.id.devId);
devIdView.setText(devId);
Button start = (Button) findViewById(R.id.start);
start.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
startAPNS();
v.setEnabled(false);
}
});
}
private void startAPNS(){
// 启动服务
Intent intent = new Intent(APNService.START);
intent.putExtra("ch", "test"); // channel name, 登录开发者页面查看
intent.putExtra("devId", devId); // 请确保 devId 不为空, devId 可为任何标识此用户的 String
startService(intent);
}
private void stopAPNS(){
// 启动服务
Intent intent = new Intent(APNService.STOP);
startService(intent);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
APNS_example_131523.zip (31个子文件)
APNSDemo
.project 844B
.DS_Store 6KB
src
.DS_Store 6KB
com
.DS_Store 6KB
apns
.DS_Store 6KB
demo
MyBroadcastReceiver.java 1KB
APNSDemo.java 1KB
lib
apns_beta_20110831.jar 12KB
AndroidManifest.xml 1KB
res
drawable
icon.png 3KB
Thumbs.db 4KB
layout
main.xml 570B
values
strings.xml 158B
assets
gen
com
apns
demo
R.java 753B
default.properties 449B
.classpath 365B
bin
resources.ap_ 5KB
.DS_Store 6KB
APNSDemo.apk 16KB
com
.DS_Store 6KB
apns
.DS_Store 6KB
demo
R$layout.class 379B
R$drawable.class 385B
R$attr.class 325B
APNSDemo.class 2KB
MyBroadcastReceiver.class 2KB
APNSDemo$1.class 791B
R$id.class 397B
R.class 496B
R$string.class 412B
classes.dex 17KB
共 31 条
- 1
playbar
- 粉丝: 473
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页