List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:com.example.tacademy.miniproject.gcm.MyGcmListenerService.java
@Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { // message received from some topic. } else {/*w ww . j a va2 s .c om*/ // normal downstream message. long lastTime = DBManager.getInstance().getLastReceiveDate(); Date date = new Date(lastTime); MessageListRequest request = new MessageListRequest(this, date); try { NetworkResult<List<ChatMessage>> result = NetworkManager.getInstance().getNetworkDataSync(request); List<ChatMessage> list = result.getResult(); for (ChatMessage m : list) { try { DBManager.getInstance().addMessage(m.getSender(), ChatContract.ChatMessage.TYPE_RECEIVE, m.getMessage(), Utils.convertStringToTime(m.getDate())); Intent i = new Intent(ACTION_CHAT); i.putExtra(EXTRA_CHAT_USER, m.getSender()); mLBM.sendBroadcastSync(i); boolean processed = i.getBooleanExtra(EXTRA_RESULT, false); if (!processed) { sendNotification(m); } } catch (ParseException e) { e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } } // sendNotification(message); }
From source file:com.flowzr.activity.DateFilterActivity.java
private void setCorrectPeriods(Intent intent) { if (intent != null && intent.getBooleanExtra(EXTRA_FILTER_SHOW_PLANNER, false)) { periods = PeriodType.allPlanner(); }/*from w w w .j a v a2 s. c o m*/ }
From source file:com.begentgroup.miniproject.gcm.MyGcmListenerService.java
@Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { } else {/* w ww . j a v a 2 s . c om*/ long lastTime = DBManager.getInstance().getLastReceiveDate(); Date date = new Date(lastTime); MessageListRequest request = new MessageListRequest(this, date); try { NetworkResult<List<ChatMessage>> result = NetworkManager.getInstance().getNetworkDataSync(request); List<ChatMessage> list = result.getResult(); for (ChatMessage m : list) { try { DBManager.getInstance().addMessage(m.getSender(), ChatContract.ChatMessage.TYPE_RECEIVE, m.getMessage(), Utils.convertStringToTime(m.getDate())); Intent i = new Intent(ACTION_CHAT); i.putExtra(EXTRA_CHAT_USER, m.getSender()); mLBM.sendBroadcastSync(i); boolean processed = i.getBooleanExtra(EXTRA_RESULT, false); if (!processed) { sendNotification(m); } } catch (ParseException e) { e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } } // sendNotification(message); }
From source file:com.tacademy.coffeejjim.miniproject.gcm.MyGcmListenerService.java
@Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { } else {/*from w w w .j a v a2 s .c o m*/ long lastTime = DBManager.getInstance().getLastReceiveDate(); Date date = new Date(lastTime); MessageListRequest request = new MessageListRequest(this, date); try { NetworkResult<List<ChatMessage>> result = NetworkManager.getInstance().getNetworkDataSync(request); List<ChatMessage> list = result.getResult(); for (ChatMessage m : list) { try { DBManager.getInstance().addMessage(m.getSender(), ChatContract.ChatMessage.TYPE_RECEIVE, m.getMessage(), Utils.convertStringToTime(m.getDate())); Intent i = new Intent(ACTION_CHAT); i.putExtra(EXTRA_CHAT_USER, m.getSender()); mLBM.sendBroadcastSync(i); boolean processed = i.getBooleanExtra(EXTRA_RESULT, false); if (!processed) { sendNotification(m); } } catch (ParseException e) { e.printStackTrace(); } } } catch (IOException e) { e.printStackTrace(); } } // sendNotification(message); }
From source file:ca.mudar.parkcatcher.service.SyncService.java
@Override protected void onHandleIntent(Intent intent) { final boolean isLocal = intent.getBooleanExtra(Const.INTENT_EXTRA_SERVICE_LOCAL, false); final boolean isRemote = intent.getBooleanExtra(Const.INTENT_EXTRA_SERVICE_REMOTE, false); final ResultReceiver receiver = intent.getParcelableExtra(EXTRA_STATUS_RECEIVER); if (receiver != null) { receiver.send(STATUS_RUNNING, Bundle.EMPTY); }/*from w ww .j a v a 2 s.c om*/ try { // Bulk of sync work, performed by executing several fetches from // local and online sources. if (isLocal) { syncLocal(); ((ParkingApp) getApplicationContext()).setHasLoadedData(true); } if (isRemote) { syncRemote(); ((ParkingApp) getApplicationContext()).setHasLoadedData(true); } } catch (HandlerException e) { e.printStackTrace(); if (receiver != null) { /** * Pass back error to surface listener */ final Bundle bundle = new Bundle(); bundle.putString(Intent.EXTRA_TEXT, e.toString()); receiver.send(STATUS_ERROR, bundle); } } if (receiver != null) { receiver.send(STATUS_FINISHED, Bundle.EMPTY); } }
From source file:anakiou.com.picontrol.service.OutputIntentService.java
private void handleSingleControl(Intent intent) { int no = intent.getIntExtra(Constants.EXTRA_NO, 0); boolean ctrlValue = intent.getBooleanExtra(Constants.EXTRA_CTRL_VALUE, false); int value = outputService.setControl(no, ctrlValue); if (value == -1) { deliverResultToReceiver(Constants.FAILURE_RESULT, getString(R.string.failed_to_send_control)); }/*from w w w. j ava 2s.c om*/ for (Output out : outputDAO.findAll()) { if (out.getOutputNumber() == no) { out.setOutputStatus(value); outputDAO.update(out); break; } } deliverResultToReceiver(Constants.SUCCESS_RESULT, getString(R.string.control_sent)); }
From source file:com.android.calendar.event.EditEventActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.simple_frame_layout); mEventInfo = getEventInfoFromIntent(icicle); mReminders = getReminderEntriesFromIntent(); mEventColorInitialized = getIntent().hasExtra(EXTRA_EVENT_COLOR); mEventColor = getIntent().getIntExtra(EXTRA_EVENT_COLOR, -1); mEditFragment = (EditEventFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config); if (mIsMultipane) { getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE); getActionBar().setTitle(mEventInfo.id == -1 ? R.string.event_create : R.string.event_edit); } else {//from w w w . j av a 2s.com getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM); } if (mEditFragment == null) { Intent intent = null; boolean readOnly = false; if (mEventInfo.id == -1) { intent = getIntent(); readOnly = intent.getBooleanExtra(EXTRA_READ_ONLY, false); } mEditFragment = new EditEventFragment(mEventInfo, mReminders, mEventColorInitialized, mEventColor, readOnly, intent); mEditFragment.mShowModifyDialogOnLaunch = getIntent() .getBooleanExtra(CalendarController.EVENT_EDIT_ON_LAUNCH, false); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.main_frame, mEditFragment); ft.show(mEditFragment); ft.commit(); } }
From source file:com.pindroid.activity.SaveReadLaterBookmark.java
private void saveBookmark(Intent intent, ShareCompat.IntentReader reader, String url) { Bookmark bookmark = new Bookmark(); bookmark.setUrl(url);/* w w w.jav a2 s. c o m*/ bookmark.setDescription(reader.getSubject()); bookmark.setShared( !intent.getBooleanExtra(Constants.EXTRA_PRIVATE, SettingsHelper.getPrivateDefault(this))); bookmark.setToRead(true); bookmark.setTime(new Date().getTime()); bookmark.setTagString(""); bookmark.setAccount(app.getUsername()); pushBookmarkToService(bookmark); Toast.makeText(this, R.string.save_later_saved, Toast.LENGTH_SHORT).show(); finish(); }
From source file:com.sbhstimetable.sbhs_timetable_android.backend.service.NotificationService.java
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { final String action = intent.getAction(); if (ACTION_CHECK_UPDATES.equals(action)) { final boolean doAll = intent.getBooleanExtra(EXTRA_SHOULD_DO_ALL, false); handleCheckUpdate(doAll);/*w w w .j av a 2 s. c o m*/ } else if (ACTION_UPDATE_NOTIFICATION.equals(action)) { handleNotificationUpdate(); } } }
From source file:br.pro.menotti.opus.pt.DisplayPoints.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Intent intent = getIntent(); final int book = intent.getIntExtra("book", 0); int chapter = intent.getIntExtra("chapter", 0); final String search_key = intent.getStringExtra("search_key"); final boolean favorites = intent.getBooleanExtra("favorites", false); db = new SQLiteHelper(this); db.openDataBase();/*from w w w .j a v a 2 s . c o m*/ // final String book_name = db.getBook(book).toString(); ListView lv = (ListView) findViewById(android.R.id.list); lv.setFastScrollEnabled(true); if (favorites) { setTitle(getString(R.string.display_favorites)); List<BookPoint> points = new ArrayList<BookPoint>(); points = db.getFavoritePoints(); lv.setAdapter(new ArrayAdapter<BookPoint>(this, android.R.layout.simple_list_item_1, points)); } else if (search_key != null) { setTitle(getString(R.string.display_search) + ": " + search_key); List<BookPoint> points = new ArrayList<BookPoint>(); points = db.getPoints(search_key); lv.setAdapter(new ArrayAdapter<BookPoint>(this, android.R.layout.simple_list_item_1, points)); } else { setTitle(db.getBook(book) + ": " + db.getChapter(book, chapter)); List<BookPoint> points = new ArrayList<BookPoint>(); points = db.getBookPoints(book, chapter); lv.setAdapter(new ArrayAdapter<BookPoint>(this, android.R.layout.simple_list_item_1, points)); } lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { db = new SQLiteHelper(getBaseContext()); db.openDataBase(); BookPoint bp = (BookPoint) parent.getItemAtPosition(position); DialogFragment newFragment = new DialogPoint(bp, favorites); newFragment.show(getSupportFragmentManager(), bp.toString()); db.close(); return true; } }); db.close(); }