Android Payment Access (iv): Unicom VAC Billing

Source: Internet
Author: User

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

Precautions:

1. Unicom payment is not required to identify the soft and hard billing points, when the platform to apply for billing points will be submitted to each billing point is allowed to repeat the payment (that is, the soft and hard billing points), payment we only need to pass the corresponding billing point, the platform will help us record which is soft billing point, which is the hard billing point.

2. Unicom is required to copy the Premessable.txt file to the project assets directory, to configure the channel, each channel corresponding to the different channel number, for example, China Unicom channel number is: "00012243".

3. Pay directly after the game is paid, do not add additional information, such as: Toast,alertdialog.

Application developer ID is correctly configured in 4.androidmanifest.xml, Application id,appid, channel pseudo code (offline channel) can be tested after payment (0.01 RMB)

Androidmanifest.xml

[HTML]View Plaincopy
  1. <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" >          <ActivityAndroid:name= "Com.example.blogforlt.MainActivity"Android:label= "@string/app_name" >              <Intent-filter>                  <ActionAndroid:name= "Android.intent.action.MAIN" />                    <categoryAndroid:name= "Android.intent.category.LAUNCHER" />              </Intent-filter>          </Activity>                   <!--app developer ID cpId: -          <Meta-dataAndroid:name= "CpId"Android:value= "Cpid:xxxx" >          </Meta-data>            <!--app ID AppId: -          <Meta-dataAndroid:name= "AppId"Android:value= "Appid:xxxx" >          </Meta-data>            <!--channel pseudo-code (offline channel) -          <Meta-dataAndroid:name= "Fidsms"Android:value= "Fidsms:xxxxx" >          </Meta-data>               </Application>        <uses-permissionAndroid:name= "Android.permission.INTERNET"/>   <uses-permissionAndroid:name= "Android.permission.ACCESS_NETWORK_STATE"/>   <uses-permissionAndroid:name= "Android.permission.ACCESS_WIFI_STATE"/>   <uses-permissionAndroid:name= "Android.permission.CHANGE_WIFI_STATE"/>   <uses-permissionAndroid:name= "Android.permission.CHANGE_NETWORK_STATE"/>   <uses-permissionAndroid:name= "Android.permission.SEND_SMS"/>   <uses-permissionAndroid:name= "Android.permission.READ_PHONE_STATE"/>   <uses-permissionAndroid:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>  

[HTML]View Plaincopy
[HTML]View Plaincopy

Mainactivity.java

[Java]View Plaincopy
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);  }    }); Fiap.java [Java] View plaincopy PackageCOM.EXAMPLE.BLOGFORLT; ImportCom.multimode_billing_sms.ui.MultiModePay; ImportCom.multimode_billing_sms.ui.MultiModePay.SMSCallBack; Importandroid.app.Activity; ImportAndroid.os.Handler; ImportAndroid.util.Log; ImportAndroid.widget.Toast;  Public classFIAP {PrivateActivity mactivity; //Billing point Short code PrivateString Charge_point; //Item Name PrivateString itemid= ""; //Item Amount Private intcoin;  PublicFiap (activity activity) {mactivity=activity; }        //index is the identification of three billing points  Public voidAndroid_pay (intindex) {        Switch(index) { Case0:     //activating the game//The billing point here fills in the post three digits of the billing point for the mobile platform application as the billing point indexCharge_point = "000"; ItemID= "Activate Game"; Coin= 6;  Break;  Case1: Charge_point= "001"; ItemID= "Buy 200 Coins"; Coin= 2;  Break;  Case2: 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) {multimodepay.getinstance (). Setenablesend (true);//The SMS method must be called before calling the//The parameters are: context of the current interface, company name, phone number, game name, item name, item amount (yuan), billing point, Callback interfaceMultimodepay.getinstance (). SMS (mactivity, "Beijing XXXXXX Co., Ltd.",        "010-xxxxxxxx", "XXX", ItemID, string.valueof (coin), Charge_point,Newmsgcallback ());   }    };      }; classMsgcallbackImplementsSmscallback {@Override Public voidButtonClick (intarg0) {     //TODO auto-generated Method Stub} @Override Public voidSmsresult (intresult, String arg1) {     //TODO auto-generated Method Stub   if(Result = =multimodepay.success) {//payment of successful processing, direct execution of payment after the logic of success, here in order to reflect the success of the payment to play a toast, formal use do not have any hintToast.maketext (mactivity, "payment Success", Toast.length_long). Show (); LOG.I ("Cn.catcap.qhta", "Unicom way to pay success ...." "); } Else if(Result = =multimodepay.faild) {log.i ("Cn.catcap.qhta", "Unicom way payment failed ...." "); } multimodepay.getinstance (). Dismissprogressdialog (); //Cancel the progress bar, the line must have to return to the game interface  }   }  }  

At this point, the Android three operators of the SDK paid access has been completed

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.