List of usage examples for android.content Intent getSerializableExtra
public Serializable getSerializableExtra(String name)
From source file:com.dmsl.anyplace.SearchPOIActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { // get the search type mSearchType = (SearchTypes) intent.getSerializableExtra("searchType"); if (mSearchType == null) finishSearch("No search type provided!", null); // get the query string final String query = intent.getStringExtra("query"); double lat = intent.getDoubleExtra("lat", 0); double lng = intent.getDoubleExtra("lng", 0); AnyplaceSuggestionsTask mSuggestionsTask = new AnyplaceSuggestionsTask( new AnyplaceSuggestionsTask.AnyplaceSuggestionsListener() { @Override//from www .ja v a 2 s . c o m public void onSuccess(String result, List<? extends IPoisClass> pois) { // we have pois to query for a match mQueriedPoisStr = new ArrayList<Spanned>(); mQueriedPois = pois; // Display part of Description Text Only // Make an approximation of available space based on map size final int viewWidth = (int) (findViewById(R.id.txtResultsFound).getWidth() * 2); View infoWindow = getLayoutInflater() .inflate(R.layout.queried_pois_item_1_searchactivity, null); TextView infoSnippet = (TextView) infoWindow; TextPaint paint = infoSnippet.getPaint(); // Regular expression // ?i ignore case Pattern pattern = Pattern.compile(String.format("((?i)%s)", query)); for (IPoisClass pm : pois) { String name = "", description = ""; Matcher m; m = pattern.matcher(pm.name()); // Makes matched query bold using HTML format // $1 returns the regular's expression outer parenthesis value name = m.replaceAll("<b>$1</b>"); m = pattern.matcher(pm.description()); if (m.find()) { // Makes matched query bold using HTML format // $1 returns the regular's expression outer parenthesis value int startIndex = m.start(); description = m.replaceAll("<b>$1</b>"); description = AndroidUtils.fillTextBox(paint, viewWidth, description, startIndex + 3); } mQueriedPoisStr.add(Html.fromHtml(name + "<br>" + description)); } ArrayAdapter<Spanned> mAdapter = new ArrayAdapter<Spanned>( // getBaseContext(), R.layout.queried_pois_item_1, getBaseContext(), R.layout.queried_pois_item_1_searchactivity, mQueriedPoisStr); lvResultPois.setAdapter(mAdapter); txtResultsFound.setText("Results found [ " + mQueriedPoisStr.size() + " ]"); } @Override public void onErrorOrCancel(String result) { // no pois exist finishSearch("No Points of Interest exist!", null); } @Override public void onUpdateStatus(String string, Cursor cursor) { SimpleCursorAdapter adapter = new SimpleCursorAdapter(getBaseContext(), R.layout.queried_pois_item_1_searchactivity, cursor, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 }, new int[] { android.R.id.text1 }); lvResultPois.setAdapter(adapter); txtResultsFound.setText("Results found [ " + cursor.getCount() + " ]"); } }, this, mSearchType, new GeoPoint(lat, lng), query); mSuggestionsTask.execute(); } }
From source file:com.github.mobile.ui.issue.IssuesFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == ISSUE_FILTER_EDIT && data != null) { IssueFilter newFilter = (IssueFilter) data.getSerializableExtra(EXTRA_ISSUE_FILTER); if (!filter.equals(newFilter)) { filter = newFilter;/*from ww w. ja v a2s.c o m*/ updateFilterSummary(); pager.reset(); refreshWithProgress(); return; } } if (requestCode == ISSUE_VIEW) { notifyDataSetChanged(); forceRefresh(); return; } if (requestCode == ISSUE_CREATE && resultCode == RESULT_OK) { Issue created = (Issue) data.getSerializableExtra(EXTRA_ISSUE); forceRefresh(); startActivityForResult(IssuesViewActivity.createIntent(created, repository), ISSUE_VIEW); return; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.grass.caishi.cc.service.BaseIntentService.java
/** * You should not override this method for your IntentService. Instead, * override {@link #onHandleIntent}, which the system calls when the * IntentService receives a start request. * /*from w w w . jav a 2 s .c o m*/ * @see android.app.Service#onStartCommand */ @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { int ddo = intent.getIntExtra("do", 0); if (ddo != 0) { SendBean send = (SendBean) intent.getSerializableExtra("send"); Message msg = mServiceHandler.obtainMessage(); msg.arg1 = send.getSend_id(); msg.what = send.getSend_id(); Bundle b = new Bundle(); b.putSerializable("send", send); msg.setData(b); // filelist.add(send); mServiceHandler.sendMessage(msg); intent.putExtra("do", UP_ADD); sendBroadcast(intent); } } return START_NOT_STICKY; }
From source file:org.melato.bus.android.activity.PointSelectionActivity.java
/** Called when the activity is first created. */ @Override// www . j a va 2s .c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.point_selection); Intent intent = getIntent(); IntentHelper intentHelper = new IntentHelper(intent); setTitle(R.string.point_selection); rstop = intentHelper.getRStop(); if (rstop == null) { point = (NamedPoint) intent.getSerializableExtra(POINT); } if (rstop == null && point == null) { Point2D p = IntentHelper.getLocation(intent); if (p != null) { point = new NamedPoint(p); } else { LabeledPoint labeledPoint = Locations.getGeoUri(intent); if (labeledPoint != null) { point = new NamedPoint(labeledPoint.getPoint(), labeledPoint.getLabel()); } } } if (point != null && point.getName() != null) { setTitle(point.getName()); } initButton(R.id.nearby); //initButton(R.id.add_stop_after); initButton(R.id.origin); initButton(R.id.destination); initButton(R.id.bookmark); }
From source file:com.jameswolfeoliver.pigeon.Services.MessageReplyService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Bundle results = RemoteInput.getResultsFromIntent(intent); String message = results != null ? results.getCharSequence(MESSAGE_TEXT_KEY).toString() : null; Conversation conversation = (intent.getExtras() != null) ? (Conversation) intent.getSerializableExtra(CONVERSATION_KEY) : null;/* ww w. ja v a 2s . c om*/ if (conversation == null || message == null) { Toast.makeText(PigeonApplication.getAppContext(), "An error occurred", Toast.LENGTH_SHORT).show(); return super.onStartCommand(intent, flags, startId); } sendTextMessage(conversation, message); return super.onStartCommand(intent, flags, startId); }
From source file:hu.naturlecso.naturshutd.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == EditActivity.EDIT_REQUEST_CODE) { if (resultCode == RESULT_OK) { Long id = data.getLongExtra(EditActivity.EDIT_RESULT_ID, INVALID_ID); EditActivity.ModelType modelType = (EditActivity.ModelType) data .getSerializableExtra(EditActivity.EXTRA_EDIT_MODEL_TYPE); switch (modelType) { case HOST: updateHost(id);//from w ww. ja v a 2s. c om break; case COMMAND: EditActivity.OperationType operationType = (EditActivity.OperationType) data .getSerializableExtra(EditActivity.EXTRA_EDIT_OPERATION_TYPE); doCommandOperation(operationType, id); break; default: throw new UnsupportedOperationException("Unknown ModelType."); } } } }
From source file:com.kangsoo.pharmacy.fragment.IssuesFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && requestCode == ISSUE_FILTER_EDIT && data != null) { ShoppingItem newFilter = (ShoppingItem) data.getSerializableExtra(EXTRA_ISSUE_FILTER); // if (!filter.equals(newFilter)) { // filter = newFilter; // updateFilterSummary(); // pager.reset(); // refreshWithProgress(); // return; // } }/*from w w w .ja v a2 s . com*/ if (requestCode == ISSUE_VIEW) { notifyDataSetChanged(); forceRefresh(); return; } if (requestCode == ISSUE_CREATE && resultCode == RESULT_OK) { Issue created = (Issue) data.getSerializableExtra(EXTRA_ISSUE); forceRefresh(); //kskim to-do // startActivityForResult(IssuesViewActivity.createIntent(created, repository), ISSUE_VIEW); return; } super.onActivityResult(requestCode, resultCode, data); }
From source file:cmput301.f13t01.readstory.ReadFragmentActivity.java
/** * Called when the activity is first created. Receives intent from main * activity to create the first fragment. *///from www . j a v a 2 s . c om @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); app = (GlobalManager) getApplication(); save = GlobalManager.getLocalManager(); setContentView(R.layout.activity_view_fragment); // if it is not starting from beginning, start reading according to // history if (savedInstanceState != null) { storyId = (UUID) savedInstanceState.getSerializable(getResources().getString(R.string.story_id)); app.setStoryManager(storyId); this.storyManager = app.getStoryManager(); fragmentId = storyManager.getMostRecent(); } else { // intent has the story ID, and story fragment ID to display Intent intent = getIntent(); // receive id of story fragment to show storyId = (UUID) intent.getSerializableExtra(getResources().getString(R.string.story_id)); // set the story in the story manager app.setStoryManager(storyId); this.storyManager = app.getStoryManager(); // depending if we are reading from beginning, // fetch the appropriate fragment ID accordingly Boolean fromBeginning = (boolean) intent .getBooleanExtra(getResources().getString(R.string.story_continue), false); if (fromBeginning) { storyManager.clearHistory(); fragmentId = storyManager.getFirstPageId(); } else { // show first page if the story has never been read fragmentId = storyManager.getMostRecent(); if (fragmentId == null) { fragmentId = storyManager.getFirstPageId(); } } // if there is no first page set, exit readmode if (fragmentId == null) { Toast.makeText(getBaseContext(), "First page has not been set for this story!", Toast.LENGTH_LONG) .show(); finish(); } } commitFragment(fragmentId); }
From source file:eu.power_switch.gui.fragment.configure_timer.ConfigureTimerDialogPage4TabbedSummaryFragment.java
@Nullable @Override//from w w w.j a va2 s.c om public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.dialog_fragment_configure_timer_page_4_summary, container, false); // BroadcastReceiver to get notifications from background service if room data has changed broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (LocalBroadcastConstants.INTENT_TIMER_NAME_EXECUTION_TIME_CHANGED.equals(intent.getAction())) { currentExecutionTime = (Calendar) intent.getSerializableExtra("executionTime"); currentName = intent.getStringExtra("name"); } else if (LocalBroadcastConstants.INTENT_TIMER_EXECUTION_INTERVAL_CHANGED .equals(intent.getAction())) { currentExecutionInterval = intent.getLongExtra("executionInterval", -1); currentExecutionDays = (ArrayList<WeekdayTimer.Day>) intent .getSerializableExtra("executionDays"); currentExecutionType = intent.getStringExtra("executionType"); } else if (LocalBroadcastConstants.INTENT_TIMER_ACTIONS_CHANGED.equals(intent.getAction())) { currentActions = (ArrayList<Action>) intent.getSerializableExtra("actions"); } updateUi(); notifyConfigurationChanged(); } }; textViewName = (TextView) rootView.findViewById(R.id.textView_name); textViewTime = (TextView) rootView.findViewById(R.id.textView_time); textViewDays = (TextView) rootView.findViewById(R.id.textView_execution_days); textViewAction = (TextView) rootView.findViewById(R.id.textView_action); Bundle args = getArguments(); if (args != null && args.containsKey(ConfigureTimerDialog.TIMER_ID_KEY)) { currentId = args.getLong(ConfigureTimerDialog.TIMER_ID_KEY); initializeTimerData(currentId); } checkSetupValidity(); updateUi(); return rootView; }
From source file:org.sufficientlysecure.keychain.remote.ui.RemoteSecurityProblemDialogActivity.java
@Override protected void onStart() { super.onStart(); Intent intent = getIntent(); String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME); Serializable keySecurityProblem = intent.getSerializableExtra(EXTRA_SECURITY_PROBLEM); boolean supportOverride = intent.getBooleanExtra(EXTRA_SUPPORT_OVERRIDE, false); presenter.setupFromIntentData(packageName, keySecurityProblem, supportOverride); }