如果广播接收器通过清单文件注册如何阅读从一个广播接收器的活动数据???请帮助...
How to read data from an activity in an broadcast receiver if the broadcast receiver is registered through the manifest file??? Please Help...
首先,你需要存储在共享preferences数据,然后让他们到广播接收器。
First you need to store data in SharedPreferences and then get them into broadcast receiver.
您可以在清单文件中使用code如下:
You can use the code below in manifest file :
<receiver android:name=".YourReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
在code您可以使用:
and in code you can use :
public class YourReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if(intent.getAction().equals("android.intent.action.BOOT_COMPLETED"))
{
//updateWidget();
SharedPreferences prfs = context.getSharedPreferences("defaul", 0);
boolean bb=prfs.getBoolean("eer",false);
alarm=context.getSharedPreferences("def", 0).getString("alarm_time","");
}
}
}