Android to share micro-trust friends and Flash-back solutions _android

Source: Internet
Author: User

1. Application for micro-letter AppID

To achieve the function of sharing to the micro-letter, first of all, to the micro-trust open platform to apply for a appid. However, when applying for AppID, you need to fill out an application signature and application package name. It is important to note that the package name must be the same as the package name when the application was developed, and the application signature must also have the colon removed and the letter lowercase.

2. Application of Signature acquisition

There are many people who develop Android applications, and it's possible that the name of the class and the name of the package are the same, and that the signature is a distinguishing function.

All Android apps must have digital signatures, and there is no application without digital signatures, including the emulator running. Simulator development environment, when developed, the program uploaded through the ADB interface will automatically be signed with debug permissions before being passed to the simulator. Open Eclipse's window-->preferences-->android-->buid menu option as shown in the following illustration, which shows the default debug signed digital certificate.

However, the use of the micro-letter sharing function requires the use of the formal release of the Android application of the signature, there will be no flash-back phenomenon.

To generate the signature of an officially released application, first we need a keystore:

The cmd command line goes to the JDK's Bin directory, so that the Android.keystore file that will be generated will be in this directory; Enter the bin directory

Keytool-genkey-alias android.keystore-keyalg rsa-validity 20000-keystore android.keystore

The input keystore password is then displayed:

Enter new password again:

What is your name and last name?

What is your organizational unit name?

What is your organization's name?

......

Finally, you should confirm that the above information is correct and enter Y

Enter <android.keystore> master password (if same as KeyStore password, press ENTER): (Master I pressed Enter)

Then back to eclipse, right-click the project-->android Tools-->export signed Application Packages, select the project name you want to Export, click Next,use Existing Keystore,location Select the JDK in the bin directory just generated android.keystore, enter the password just set in cmd, click Next, enter the password again, click Next, select APK location, the following figure

MD5 is the application signature we need to enter on the micro-trust platform (note that the letters are lowercase and the colon is removed).

In the micro-credit development platform Click Submit Audit, generally within one day can pass the audit, at this time in the management center, we can see AppID

3. Use of the micro-credit sharing function in the application

Create a micro-credit API

private static final String app_id = "applied to AppID"; 
Private IWXAPI API; 
@Override public 
void OnCreate (Bundle savedinstancestate) { 
super.oncreate (savedinstancestate); 
API = Wxapifactory.createwxapi (Getactivity (), app_id); 
Api.registerapp (app_id); 
} 
[Java] View plain copy on the code to see a piece of coding derived from my Code
///Create a Wxtextobject object that encapsulates the text to be shared 
wxtextobject textobject = new Wxtextobject (); 
Textobject.text = Text;//text text string to be shared 
//step 2nd: Create Wxmediamessage object for Android client to send data 
to micro-mail Wxmediamessage msg = new Wxmediamessage (); 
Msg.mediaobject = Textobject; 
Msg.description = "schedule Information"; 
Step 3rd: Create a Sendmessagetowx.req object to request the micro-client 
sendmessagetowx.req Req = new Sendmessagetowx.req (); 
Req.message = msg; 
Sets the unique identification of the request 
req.transaction = buildtransaction (text); 
Req.scene = SendMessageToWX.Req.WXSceneSession; 
4th step: Send to micro-letter customer service end 

After each modification of the debugging to export once apk, and then install APK, unless the debugging micro-letter sharing function can be directly run; Call other APIs such as Baidu Map need to apply the signature, also pay attention to debug when the signature and the formal release of the application of the signature is not the same.

The above content is small series to introduce the Android to share micro-trust friends and the emergence of a flash-back solution, I hope to help you!

Related Article

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.