网站首页
uniapp 去除应用的uni-AD状态异常
发布时间:2020-11-04 03:02查看次数:2291
import android.app.Activity; import android.content.Context; import android.os.Bundle; import io.dcloud.application.DCloudApplication; public class MyApplication extends DCloudApplication { @Override public void onCreate() { super.onCreate(); removeAdTip(this); registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { removeAdTip(activity); } @Override public void onActivityStarted(Activity activity) { } @Override public void onActivityResumed(Activity activity) { } @Override public void onActivityPaused(Activity activity) { } @Override public void onActivityStopped(Activity activity) { } @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) { } @Override public void onActivityDestroyed(Activity activity) { removeAdTip(activity); } }); } /** * 移除DCloud广告toast提示 * * @param context */ private void removeAdTip(Context context) { context.getSharedPreferences("_adio.dcloud.feature.ad.dcloud.ADHandler", Context.MODE_PRIVATE) .edit() .clear() .apply(); } }
<application android:name=".MyApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" android:largeHeap="true" android:theme="@style/AppTheme" tools:replace="android:name"> //省略其他配置... </application>
关键字词:uniapp