米娅的android之旅
android开发群群号:84926730

发送定位广播:

Intent intent = new Intent();
intent.putExtra("GpsIsAvailable", GPS_IS_AVAILABLE);
intent.setAction("cn.com.miya.action.service");
sendBroadcast(intent)


注册广播接收者:

private GpsStatusReceiver receiver = new GpsStatusReceiver();
IntentFilter filter = new IntentFilter("cn.com.miya.action.service");
GpsStatus.this.registerReceiver(receiver, filter);

接收广播的部分一定要unregister:

@Override
protected void onStop() {
unregisterReceiver(receiver);
super.onStop();
}  

接收广播类:

public class GpsStatusReceiver extends BroadcastReceiver{
    @Override
    public void onReceive(Context context, Intent intent) {
            
        //做一些修改界面之类的工作
    }
}

 

 

posted on 2012-09-13 15:27  程序缘儿  阅读(4991)  评论(0编辑  收藏  举报