Android 微信登錄/分享集成指南(原生)

現在一些主流的APP都有微信登錄 / 支付 / 分享等功能,下面是集成指南

1.需要有微信開發者賬號,並且有微信登錄 支付的權限

Builder.Gradle中

implementation 'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:+'

然後Manifest中

<activity
    android:name=".wxapi.WXPayEntryActivity"
    android:exported="true"
    android:launchMode="singleTop">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />

        <category android:name="android.intent.category.DEFAULT" />

        <data android:scheme="你的id" />
    </intent-filter>
</activity>
<activity
    android:name=".wxapi.WXEntryActivity"
    android:exported="true" />

 

<receiver
    android:name=".wxapi.AppRegister"
    android:exported="false">
    <intent-filter>
        <action android:name="com.tencent.mm.plugin.openapi.Intent.ACTION_REFRESH_WXAPP" />
    </intent-filter>
</receiver> 

//在你的包名下新建wxapi包 demo中有

 

 

//調起的方法

if (!MainApplication.mWxApi.isWXAppInstalled()) {
    ToastUtils.show("您的設備未安裝微信客戶端");
} else {
    final SendAuth.Req req = new SendAuth.Req();
    req.scope = "snsapi_userinfo";
    req.state = "wechat_sdk_demo_test";
    MainApplication.mWxApi.sendReq(req);
}

 

WXEntryActivity.java/登錄分享
WXPayEntryActivity//支付

支付需要後臺生成訂單 然後調起

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章