标签:android style blog http java color
原地址:http://blog.csdn.net/simdanfeg/article/details/9011977
MainActivity.java
package com.example.blogfordx; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.view.View; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.button1).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Fiap fiap = new Fiap(MainActivity.this); fiap.android_Pay(1); } }); findViewById(R.id.button2).setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // 更多游戏接口 Uri uri = Uri .parse("http://wapgame.189.cn/c/index.html"); Intent in = new Intent(Intent.ACTION_VIEW, uri); MainActivity.this.startActivity(in); } }); } } EgameSplash.java: [java] view plaincopy package com.example.blogfordx; import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class EgameSplash extends Activity { private int count = 0; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.splash); new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub while (count <= 2) { count++; try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Intent intent = new Intent(EgameSplash.this, MainActivity.class); startActivity(intent); EgameSplash.this.finish(); } }).start(); } } Fiap.java [java] view plaincopy package com.example.blogfordx; import cn.game189.sms.SMS; import cn.game189.sms.SMSListener; import android.app.Activity; import android.os.Handler; import android.util.Log; import android.widget.Toast; public class Fiap { private Activity mActivity; // 是否允许重复计费 private boolean isRepeat; // 计费点短代码 private String charge_Point; // 道具名称 private String itemID = ""; // 支付金额 private int coin = 0; public Fiap(Activity activity) { mActivity = activity; } // index是三种计费点对应的标识 // 此处只有购买200兑换币是可支付的,正式使用时请填写自己的申请的计费点短代码 public void android_Pay(int index) { switch (index) { case 0: // 激活游戏 isRepeat = false; // 此处计费点填写电信平台申请的计费点的后三位作为计费点索引 charge_Point = "000"; itemID = "激活游戏"; coin = 4; break; case 1: isRepeat = true; charge_Point = "0211C001271102517996991102517990080115127000000000000000000000000000"; itemID = "购买200兑换币"; coin = 2; break; case 2: isRepeat = true; charge_Point = "002"; itemID = "购买400兑换币"; coin = 3; break; default: break; } fiapHandler.sendEmptyMessage(1); } Handler fiapHandler = new Handler() { public void handleMessage(android.os.Message msg) { if (msg.what == 1) { if (SMS.checkFee(itemID, mActivity, new SMSListener() { public void smsOK(String feeName) { // 短代发送成功,此处填写支付成功后的逻辑 Log.i("SMSListener", "模式" + feeName + "已计费完成,关卡已打开."); Toast.makeText(mActivity, "支付成功", Toast.LENGTH_LONG) .show(); } public void smsFail(String feeName, int errorCode) { // 短代发送失败,不给道具或不放行关卡 Log.e("SMSListener", "计费失败!模式:[" + feeName + "] 错误码:" + errorCode); } public void smsCancel(String feeName, int errorCode) { Log.e("SMSListener", "用户点击取消!计费点:" + feeName + " 错误码:" + errorCode); } }, charge_Point, itemID + ",点击确定将会发送一条" + coin + "元短信,不含信息费.", "短信已成功发送", isRepeat)) { // 已计过费 } } }; }; }
电信的计费sdk接入完成
Android支付接入(三):电信爱游戏支付,布布扣,bubuko.com
标签:android style blog http java color
原文地址:http://www.cnblogs.com/123ing/p/3850462.html