Android Payment Access (iii): Telecom Love Game payment

Source: Internet
Author: User

Original address: http://blog.csdn.net/simdanfeg/article/details/9011977

Precautions :1. Telecom requirements must start the Flash screen interface of the Telecommunications 2. Non-online games are not allowed to have Interent permissions 3. Telecom does not provide a test billing point (less than one yuan), the text of INDEX1 is a real billing point (2 yuan), payment will be real billing [HTML]View Plaincopy
Androidmanifest.xml:<ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" >          <ActivityAndroid:name= "Com.example.blogfordx.MainActivity"Android:label= "@string/app_name" >                        </Activity>                    <!--Telecom -  <ActivityAndroid:name= "Cn.game189.sms.SMS"Android:theme= "@android: Style/theme.dialog"android:screenorientation= "Portrait" ></Activity>  <!--Telecom -  <!--Start the splash screen interface -  <ActivityAndroid:name= "Com.example.blogfordx.EgameSplash"android:configchanges= "Orientation"android:screenorientation= "Portrait"Android:theme= "@android: Style/theme.notitlebar.fullscreen">              <Intent-filter>                  <ActionAndroid:name= "Android.intent.action.MAIN" />                  <categoryAndroid:name= "Android.intent.category.LAUNCHER" />              </Intent-filter>          </Activity>      </Application>            <!--single game can not have the Internet and other unrelated rights, if there are special requirements, the platform to indicate when the application, audit through the rear can be added -  <uses-permissionAndroid:name= "Android.permission.READ_PHONE_STATE" />  <uses-permissionAndroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE" />  <uses-permissionAndroid:name= "Android.permission.SEND_SMS" />  

Mainactivity.java

[Java]View Plaincopy
  1.  PackageCOM.EXAMPLE.BLOGFORDX; ImportAndroid.net.Uri; ImportAndroid.os.Bundle; Importandroid.app.Activity; Importandroid.content.Intent; ImportAndroid.view.View;  Public classMainactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);          Setcontentview (R.layout.activity_main); Findviewbyid (R.id.button1). Setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method StubFIAP FIAP =NewFIAP (mainactivity. This); Fiap.android_pay (1);          }                  }); Findviewbyid (R.id.button2). Setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {//TODO auto-generated Method Stub//More game InterfacesUri uri =Uri. Parse ("Http://wapgame.189.cn/c/index.html"); Intent in=NewIntent (Intent.action_view, URI); Mainactivity. This. StartActivity (in);      }                  }); }} Egamesplash.java: [Java] View plaincopy PackageCOM.EXAMPLE.BLOGFORDX; Importandroid.app.Activity; Importandroid.content.Intent; ImportAndroid.os.Bundle;  Public classEgamesplashextendsActivity {Private intCount = 0; @Overrideprotected voidonCreate (Bundle savedinstancestate) {//TODO auto-generated Method Stub        Super. OnCreate (savedinstancestate);          Setcontentview (R.layout.splash); NewThread (NewRunnable () {@Override Public voidrun () {//TODO auto-generated Method Stub                 while(Count <= 2) {Count++; Try{Thread.Sleep (1000); } Catch(interruptedexception e) {//TODO auto-generated Catch blockE.printstacktrace (); }} Intent Intent=NewIntent (Egamesplash. This, Mainactivity.class);                  StartActivity (Intent); Egamesplash. This. Finish ();      }}). Start (); }} Fiap.java [Java] View plaincopy PackageCOM.EXAMPLE.BLOGFORDX; ImportCn.game189.sms.SMS; ImportCn.game189.sms.SMSListener; Importandroid.app.Activity; ImportAndroid.os.Handler; ImportAndroid.util.Log; ImportAndroid.widget.Toast;  Public classFIAP {PrivateActivity mactivity; //whether to allow recurring billing    Private Booleanisrepeat; //Billing point Short code    PrivateString Charge_point; //Item Name    PrivateString ItemID = ""; //Amount Paid    Private intCoin = 0;  PublicFiap (activity activity) {mactivity=activity; }        //index is the identification of three billing points//here only the purchase of 200 coins is chargeable, please fill in the short code of the billing point of your application when used formally     Public voidAndroid_pay (intindex) {          Switch(index) { Case0:              //activating the gameIsrepeat =false; //The billing point here fills in the post three digits of the billing point for the telecom platform application as the billing point indexCharge_point = "000"; ItemID= "Activate Game"; Coin= 4;  Break;  Case1: Isrepeat=true; Charge_point= "0211c001271102517996991102517990080115127000000000000000000000000000"; ItemID= "Buy 200 Coins"; Coin= 2;  Break;  Case2: Isrepeat=true; Charge_point= "002"; ItemID= "Buy 400 Coins"; Coin= 3;  Break; default:               Break; } fiaphandler.sendemptymessage (1); } Handler Fiaphandler=NewHandler () { Public voidhandlemessage (android.os.Message msg) {if(Msg.what = = 1) {                  if(Sms.checkfee (ItemID, Mactivity,NewSmslistener () { Public voidSmsok (String feename) {//short generation sent successfully, here fill in the logic after successful paymentLOG.I ("Smslistener", "mode" + Feename + "Billing complete, Level Open.")); Toast.maketext (mactivity,"Payment Success", Toast.length_long). Show (); }                         Public voidSmsfail (String Feename,intErrorCode) {                          //short-generation send failed, no props or no release levelsLOG.E ("Smslistener", "Billing failed! Mode: [" + Feename + "] Error code:" +ErrorCode); }                         Public voidSmscancel (String Feename,intErrorCode) {LOG.E ("Smslistener", "User click Cancel!" Billing point: "+ feename +" error code: "+ErrorCode); }}, Charge_point, ItemID+ ", click OK will send a" + coin + "Meta text message, no information fee.",                          "SMS has been sent successfully", Isrepeat)) {                      //Accrued Fees                  }              }          };    }; }  

Telecom's Billing SDK access complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.