下面列出了android.content.Intent#getDoubleArrayExtra ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals(Constants.SERVICE_COMMS.MESSAGE))
{
// Debug / info message
showMessage(intent.getStringExtra(Constants.SERVICE_COMMS.MESSAGE), false);
}
else if (intent.getAction().equals(Constants.SERVICE_COMMS.LOCATION_COORDS))
{
// double[] of current coordinates
double[] centroid = intent.getDoubleArrayExtra(Constants.SERVICE_COMMS.LOCATION_COORDS);
String sCentroid = "Trilateration (centroid): ";
for (int i = 0; i < centroid.length; i++)
sCentroid += "" + (int)centroid[i] + ", ";
showMessage(sCentroid, true);
}
else if (intent.getAction().equals(Constants.SERVICE_COMMS.FINISH))
{
finishAffinity();
}
}
@Override
public void onReceive(Context context, Intent intent)
{
if (intent.getAction().equals(Constants.SERVICE_COMMS.LOCATION_COORDS))
{
// double[] of current coordinates
double[] centroid = intent.getDoubleArrayExtra(Constants.SERVICE_COMMS.LOCATION_COORDS);
// todo currently hardcoded for 2D
movePin(centroid[0], centroid[1], 0.0);
}
else if (intent.getAction().equals(Constants.SERVICE_COMMS.FINISH))
{
finishAffinity();
}
}
private void loadViewModeState() {
Intent intent = getIntent();
if (intent != null && intent.getExtras() != null) {
double[] location = intent.getDoubleArrayExtra(GeoPointWidget.LOCATION);
this.location.setLatitude(location[0]);
this.location.setLongitude(location[1]);
this.location.setAltitude(location[2]);
this.location.setAccuracy((float)location[3]);
isManualSelectedLocation = true;
inViewMode = intent.getBooleanExtra(EXTRA_VIEW_ONLY, false);
}
}
/**
* Utility to get the position from an intent.
*
* @param intent the intent.
* @return the position as lon, lat, elev.
*/
public static double[] getPosition(Intent intent) {
if (intent == null) {
return null;
}
double[] position = intent.getDoubleArrayExtra(GPS_SERVICE_POSITION);
return position;
}
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
double[] currentLocation = intent.getDoubleArrayExtra("location");
movePin(currentLocation[0], currentLocation[1], 0.0);
}
public static double[] getDoubleArrayExtra(Intent intent, String name) {
if (!hasIntent(intent) || !hasExtra(intent, name)) return null;
return intent.getDoubleArrayExtra(name);
}