I have such a problem while sending intent with extras: values put as double are converted to integer, and cannot be read as double when receiving the intent. The code is below.
creation of the Intent in onUpdate method of WidgetProvider:
Intent send = new Intent("ACTION_SEND_DATA");
send.putExtra("url", "http://some-url.com");
send.putExtra(LONGITUDE, new Double(13.65));
send.putExtra(LATITUDE, new Double(43.12));
PendingIntent sendPendingIntent = PendingIntent.getBroadcast(context, 0, send, 0);
views.setOnClickPendingIntent(R.id.Change, sendPendingIntent);
Reception of the Intent in onReceive method of WidgetProvider:
else if (intent.getAction().equals("ACTION_SEND_DATA"))
{
Log.d("WIDGET", "received ACTION_SEND_DATA intent");
String msg = intent.getStringExtra("url");
Bundle extras = intent.getExtras();
if (extras != null)
{
// Get data via the key
String url = extras.getString("url");
Double longitude = new Double(intent.getDoubleExtra(LONGITUDE, -100));
Double latitude = new Double(extras.getDouble(LATITUDE, -100));
msg = "received: " + url + " " + longitude + " " + latitude;
sendData(extras);
}
else
msg += " no extras!";
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
}
This lines:
Double longitude = new Double(intent.getDoubleExtra(LONGITUDE, -100));
Double latitude = new Double(extras.getDouble(LATITUDE, -100));
throw warning in DDMS LogCat:
What can cause this error?
To not get this warning you could use -100.0 instead because that is the Integer its complaining about. But that won't solve your problem.
Your Intent seems not to have a value for the key LONGITUDE.