Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

微信的 wxapi.WXEntryActivity 当使用别名activity-alias时,导致分享时返回错误 #10

Open
shengdoushi opened this issue Mar 18, 2020 · 0 comments

Comments

@shengdoushi
Copy link

为了多个 Android 的 flavor 配置,将 wxapi.WXEntryActivity 配置成别名 Activity, 但是 Dcloud 内部会触发 hasWXEntryActivity() 判断失败,导致拉起分享成功,却提示 Unable to send 的错误。

下面是 AndroidManifest.xml 中对 .wxapi.WXEntryActivity 的配置:

        <activity
            android:name="my.wxapi.WXEntryActivity"
            android:label="@string/app_name"
            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="wxxxxxxxxxxx"/>
            </intent-filter>
        </activity>

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

查了下代码, 应该是 hasWXEntryActivity() 内部的 Class.forName(clsName) 处不能查找到 activity-alias 类导致的。

    private boolean hasWXEntryActivity(Context context) {
        String clsName = context.getPackageName() + ".wxapi.WXEntryActivity";
        try {
            Class.forName(clsName);
            return true;
        } catch (ClassNotFoundException e) {
            return false;
        }
    }

private boolean hasWXEntryActivity(Context context) {

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant