@Override public void onClick(View v) { if (!validate()) return; String startPoint = mFromButton.getText().toString(); String endPoint = mToButton.getText().toString(); mHistoryDbAdapter.create(HistoryDbAdapter.TYPE_START_POINT, startPoint); mHistoryDbAdapter.create(HistoryDbAdapter.TYPE_END_POINT, endPoint); Intent i = new Intent(PlannerActivity.this, RoutesActivity.class) .setData(RoutesActivity.createRoutesUri(startPoint, endPoint)); startActivity(i); }
/** * Setup a search short cut. * * @param startPoint the start point * @param endPoint the end point */ protected void onCreateShortCut(String startPoint, String endPoint) { Uri routesUri = RoutesActivity.createRoutesUri(startPoint, endPoint); Intent shortcutIntent = new Intent(Intent.ACTION_VIEW, routesUri, this, RoutesActivity.class); shortcutIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // Then, set up the container intent (the response to the caller) Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, startPoint + " " + endPoint); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(this, R.drawable.icon); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource); // Now, return the result to the launcher setResult(RESULT_OK, intent); finish(); }