微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > 新增一闹钟后,从应用程序中清除闹钟数据后查看,发现待机界面闹钟图标未被清除

新增一闹钟后,从应用程序中清除闹钟数据后查看,发现待机界面闹钟图标未被清除

时间:10-02 整理:3721RD 点击:
可通过下面的方法修改这个问题
1.请Settings负责人在Settings中app的cleardata时发送broADCast
com.mediatek.intent.action.SETTINGS_PACKAGE_DATA_CLEARED出来。
2.在androidManifest文件中新增Receiver。
<receiver android:name=".PackageDataClearedReceiver">
<intent-fiLTEr>
<action android:name="com.mediatek.intent.action.SETTINGS_PACKAGE_DATA_CLEARED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
3.新增Receiver类PackageDataClearedReceiver
package com.android.deskclock;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.provider.Settings;
/**
* This receiver is used to clear status bar icon when the application data is
* cleared by settings.
*/
public class PackageDataClearedReceiver extends BroadcastReceiver {
private static final String ACTION_PACKAGE_DATA_CLEARED =
"com.mediatek.intent.action.SETTINGS_PACKAGE_DATA_CLEARED";
@Override
public void onReceive(Context context, Intent intent) {
if (!ACTION_PACKAGE_DATA_CLEARED.equals(intent.getAction())) {
return;
}
String pkgName = intent.getStringExtra("packageName"); //从Intent中获取包名,如无法获取
,请让Settings发送intent出来时将包名存入
Log.v("PackageDataClearedReceiver recevied pkgName = " + pkgName);
if (pkgName == null || !pkgName.equals(context.getPackageName())) {
return;
} //判断是否为DeskClock应用清楚数据
AlARMs.setStatusBarIcon(context, false); //清楚数据
Settings.System.putString(context.getContentResolver(),
Settings.System.NEXT_ALARM_FORMATTED,null); //重置DeskClock Activity中Set Alarm文字
}
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top