我没有成功注册或使用我的broadCastReceiver
.
这是我的代码:
public class ReciverChangeProgress extends BroadcastReceiver{
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
android.util.Log.e("ReciverChagne", "IReciver");
}
}
public ReciverChangeProgress reciverChangeProgress;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e("ReciverChange","onCreate");
setContentView(R.layout.activity_progress);
progressBar= (ProgressBar) findViewById(R.id.progressBar1);
Log.e("ReciverChange","setProgress");
progressBar.setProgress(UploadService.lastPercent);
IntentFilter intentFilter=new IntentFilter("commoshe");
registerReceiver(reciverChangeProgress,intentFilter);
android.util.Log.e("ReciverChagne", "register");
sendBroadcast(new Intent("commoshe"));
android.util.Log.e("ReciverChagne", "Use");
}
当我运行 Activity 时,这是 LogCat:
ReciverChange, onCreate
ReciverChange, setProgresS
ReciverChange, regiseter
ReciverChange, use
但是 onReceive 函数从未调用过。
谢谢您的帮助 :)