WeChat login to share how to build projects elegantly

Scenario analysis

The development process, we can not avoid, to switch back and forth the package name, and sign in to share micro-channel WXEntryActivityfile must be in the corresponding package name package.wxapi.WXEntryActivitynext to lift the micro-channel pages. Then the question is, if I have three package names to switch back and forth, how to build, for
example, your package name may be set like this,

 app = [
            mainApplicationId: "XXX",//修改此值改包名
            testApplicationId:"XXX"
    ]

At this time, are you thinking, then I use ${applicationId}it very well, how to achieve it, please see the following

solution

1. According to your own business logic, you can install them WXEntryActivityat random and write them in random positions

 <activity
            android:name="com.share.ui.WXEntryActivity"
            android:exported="true"
            android:launchMode="singleTask"
            android:theme="@android:style/Theme.Translucent.NoTitleBar">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

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

                <data android:scheme="sdksample" />
            </intent-filter>
        </activity>

2. The <activity-alias></activity-alias>label will be used ,

  <activity-alias
            android:name="${applicationId}.wxapi.WXEntryActivity"
            android:exported="true"
            android:targetActivity=".ui.WXEntryActivity">
        </activity-alias>

It can be solved perfectly through the above two steps.

Wow, a lot of code has been reduced. If it helps you, just move a little mouse and click like, I wish you a happy work,

Guess you like

Origin blog.csdn.net/honeylife/article/details/112177241