
Untitled
By: a guest on
Jun 16th, 2012 | syntax:
None | size: 1.14 KB | hits: 21 | expires: Never
Android: Data from Broadcast from AsyncTask not getting data through
public static final String LOCATION_UPDATE = "com.locationTest.lct.LOCATION_UPDATE";
char[] buffer = new char[10];
buffer[0] = 't';
buffer[1] = 'e';
buffer[2] = 's';
buffer[3] = 't';
Intent intent = new Intent(LOCATION_UPDATE);
intent.putExtra("location",buffer);
sendBroadcast(intent);
public static final String LOCATION_UPDATE = "com.locationTest.lct.LOCATION_UPDATE";
public class LocationBroadcastReceiver extends BroadcastReceiver {
public void onReceive(Context context,Intent intent)
{
Uri data = intent.getData();
CharSequence location = intent.getCharSequenceExtra("location");
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
iService = startService(new Intent(this,InputService2.class));
IntentFilter filter = new IntentFilter(LOCATION_UPDATE);
LocationBroadcastReceiver r = new LocationBroadcastReceiver();
registerReceiver(r,filter);
String location = new String(intent.getCharArrayExtra("location"));