.. include:: ../services/push.rst Android API使用手册 ========================== `点击查看 `_ 使用示例 ============= 下面使用代码来说明手机推Android服务的调用方式。 .. highlight:: java :: //appid 是应用的标识,从SAE的推送服务页面申请 int appid = 20001; //token 是SDK通道标识,从SDK的onPush中获取 String token = "BYfkQcUYULUB"; String title = "title"; String msg = "hello wolrd"; String [] acts = new String[]{"2","sina.Apns","sina.Apns.MainActivity"}; Map extra = new HashMap(); extra.put("handle_by_app", "0"); SaeADPNS adpns = new SaeADPNS(); boolean result = adpns.push(appid, token, title, msg, acts, extra); if(result){ System.out.println("发送成功"); }else{ System.out.println("发送失败"); System.out.println("错误码:"+adpns.getErrno()); System.out.println("错误信息:"+adpns.getErrmsg()); } .. note:: 推送消息跳转说明 SDK收到push消息后会发出一个Notification或是弹出一个Dialog。当用户点击Notification或Dialog上的按钮时,会发生跳转。例如跳转到App的某个Activity,或者跳转到浏览器。这种行为通过push接口中的acts字段控制。 ===================== ======= =========== ================ ================================================================ 跳转行为 行为ID 参数1 参数2 举例 ===================== ======= =========== ================ ================================================================ 跳转到App的Activity 2 App的包名 Activity的类名 {"2","com.sina.news","com.sina.news.ui.NewContentActivity"} 跳转到浏览器 4 URL地址 无 {"4","http://www.sina.com"} 通过Scheme跳转 5 Sheme 无 {"5","sinaweibo://sendweibo"} ===================== ======= =========== ================ ================================================================