我需要一点帮助。我正在尝试使用移动设备上的gps。不知道是否有效,但在此之前,我已经为该按钮设置了onclicklistener,但它不允许发送传播。任何人都有解决方案吗?如何在片段类中使用发送广播方法
public class locate extends Fragment {
Button b1;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.locate, container, false);
onCreate(savedInstanceState);
b1=(Button)rootView.findViewById(R.id.widget33);
b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Toast.makeText(Gloabal.getcontext(), "text", Toast.LENGTH_LONG).show();
Intent intent=new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
//startActivity(intent);
}
});
return rootView;
}
}
任何其他替代使用的意图,...,M卡使用滑动式标签有点为m这么多DONO周围,任何的帮助深表感谢
[广播从片段到服务的意图](http://stackoverflow.com/questions/18687444/broadcasting-an-intent-from-a-fragment-to-a-service) –