我想从“class gps_Listener”创建“Intent”并在“class LocationChangedReceiver”中发送参数
我的班级 gps_Listener
public class gps_Listener implements LocationListener {
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
send("I found the location");
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
public void send(String str) {
Intent intent = new Intent("logGPS");
intent.putExtra("Message", str);
sendBroadcast(intent); //- without context does not work
}
}
和类 LocationChangedReceiver
public class LocationChangedReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
}
}
我不知道该怎么做,因为你可以看到没有“上下文”