List of usage examples for android.content Intent getSerializableExtra
public Serializable getSerializableExtra(String name)
From source file:com.jbirdvegas.mgerrit.CardsFragment.java
public void onEventMainThread(Finished ev) { if (!getQuery().equals(ev.getStatus())) { return;// ww w .ja v a 2 s . c o m } onStopRefresh(); Intent processed = ev.getIntent(); Direction direction = (Direction) processed.getSerializableExtra(GerritService.CHANGES_LIST_DIRECTION); if (mEndlessAdapter == null || direction == Direction.Newer) return; if (ev.getItems() < sChangesLimit) { // Remove the endless adapter as we have no more changes to load mEndlessAdapter.finishedDataLoading(); } }
From source file:com.jay.pea.mhealthapp2.utilityClasses.AlarmReceiver.java
/** * OnRecieve method that recieves calls form the AlertManager class and then applies some logic to fire notifications to the user. * * @param context//from ww w .j a v a 2 s . c om * @param intent */ @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "onRecieve"); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MedMinder"); //Acquire the lock wl.acquire(); dose = null; dose = (Dose) intent.getSerializableExtra(AlertManager.ALARMSTRING); Log.d(TAG, " This dose is " + dose.getMedication().getMedName() + " " + dose.getDoseTime().toString(dtfTime)); if (dose == null) { Log.d(TAG, "Alert object Extra is null"); } //get the parent med Medication med = dose.getMedication(); int alertCount = 0; for (DateTime doseDueDT : med.getDoseMap1().keySet()) { DateTime doseTakenDT = med.getDoseMap1().get(doseDueDT); if (doseDueDT.isBefore(new DateTime().now()) && doseDueDT.isAfter(new DateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0)) && doseTakenDT.equals(new DateTime(0))) { alertCount++; } } if (alertCount == 0) { return; } SharedPreferences sharedPref = context.getSharedPreferences("AlertCounter", 0); int alertCountPref = sharedPref.getInt(med.getMedName(), 0); SharedPreferences.Editor editor = sharedPref.edit(); DateTime now = new DateTime().now(); int notifID = dose.getMedication().getDbID(); Random rand = new Random(); //int notifID = rand.nextInt(); Log.d(TAG, dose.getMedication().getDbID() + " " + dose.getDoseTime().getMillisOfDay()); if (dose.getTakenTime().toString(dtfDate).equals(new DateTime(0).toString(dtfDate))) { // if ((dose.getDoseTime().getMillis() + alertMissedWindowArray[dose.getMedication().getFreq() - 1] * 2) > new DateTime().getMillis()); String alertString = "You have " + alertCount + " missed doses for " + med.getMedName(); if (alertCount == 1) { alertString = "You have a missed dose for " + med.getMedName(); } //check if the dose is due +/- 15mins and advise that a dose is due. long diffMillis = dose.getDoseTime().getMillis() - new DateTime().now().getMillis(); Log.d(TAG, diffMillis + " dose time = " + dose.getDoseTime().getMillis() + " now= " + new DateTime().now().getMillis()); boolean doseDue = Math.abs(diffMillis) < 1800000; if (doseDue) { alertString = dose.getMedication().getDose() + " of " + dose.getMedication().getMedName() + " is due now."; } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.medminder_icon).setContentTitle("MedMinder").setContentText(alertString); Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mBuilder.setSound(alarmSound); // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(context, MainActivity.class); // The stack builder object will contain an artificial back stack for the started Activity. // This ensures that navigating backward from the Activity leads out of your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(notifID, mBuilder.build()); Log.d(TAG, " Notification sent " + notifID); // // // editor.putInt(med.getMedName(), alertCount); // editor.commit(); //Release the lock wl.release(); } }
From source file:io.v.android.impl.google.services.blessing.BlessingActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mBaseContext = V.init(this); setFinishOnTouchOutside(false);/*from w w w. ja v a 2 s . c o m*/ if (savedInstanceState != null) { mGoogleAccount = savedInstanceState.getString(STATE_GOOGLE_ACCOUNT); mPublicKey = (ECPublicKey) savedInstanceState.getSerializable(STATE_PUBLIC_KEY); mPrefKey = savedInstanceState.getString(STATE_PREF_KEY); return; } Intent intent = getIntent(); if (intent == null) { replyWithError("Intent not found."); return; } // Get the public key of the application invoking this activity. mPublicKey = (ECPublicKey) intent.getSerializableExtra(EXTRA_PUBLIC_KEY); if (mPublicKey == null) { replyWithError("Empty blesee public key."); return; } // Get the SharedPreferences key where the blessings are to be stored. If empty, blessings // aren't stored in preferences. if (intent.hasExtra(EXTRA_PREF_KEY)) { mPrefKey = intent.getStringExtra(EXTRA_PREF_KEY); } // Get the google email address (if any). mGoogleAccount = intent.getStringExtra(EXTRA_GOOGLE_ACCOUNT); if (mGoogleAccount == null || mGoogleAccount.isEmpty()) { // Prompt the user to choose the google account to use (if more than one). Intent accountIntent = AccountManager.newChooseAccountIntent(null, null, new String[] { "com.google" }, false, null, null, null, null); startActivityForResult(accountIntent, REQUEST_CODE_PICK_ACCOUNT); return; } getBlessing(); }
From source file:com.contralabs.inmap.activities.MainActivity.java
private boolean verifyIntentShowStoreOnMap(Intent i) { if (i != null) { Store store = (Store) i.getSerializableExtra(SHOW_STORE_INMAP); if (store != null) { if (isLeftMenuShowing()) toggleList();//from ww w. j a v a 2 s. c om showStoreOnMap(store); return true; } } return false; }
From source file:cmput301.f13t01.editstory.EditStoryActivity.java
@Override /**/*from w w w . ja va 2s . co m*/ * Override onCreate function */ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_edit_story); getActionBar().setDisplayHomeAsUpEnabled(false); final Button button = (Button) findViewById(R.id.edit_set_first_page); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { buttonPressed = true; showFragmentSelection(); } }); // Get the story manager GlobalManager app = (GlobalManager) getApplication(); manager = GlobalManager.getStoryManager(); if (savedInstanceState != null) { isNew = savedInstanceState.getBoolean(getResources().getString(R.string.story_is_new)); storyId = (UUID) savedInstanceState.getSerializable(getResources().getString(R.string.story_id)); app.setStoryManager(storyId); } else { Intent intent = getIntent(); isNew = (boolean) intent.getBooleanExtra(getResources().getString(R.string.story_is_new), false); if (isNew == false) { storyId = (UUID) intent.getSerializableExtra(getResources().getString(R.string.story_id)); app.setStoryManager(storyId); EditText title = (EditText) findViewById(R.id.edit_story_title); EditText author = (EditText) findViewById(R.id.edit_story_author); EditText desc = (EditText) findViewById(R.id.edit_story_description); title.setText(manager.getTitle()); author.setText(manager.getAuthor()); desc.setText(manager.getDescription()); } else { storyId = app.createAndSetStory(); } } TextView firstPage = (TextView) findViewById(R.id.edit_first_page); StoryFragment firstPageFragment = manager.getFirstPage(); if (firstPageFragment == null) { firstPage.setText(getResources().getString(R.string.first_page) + " " + getResources().getString(R.string.first_page_empty)); } else { firstPage.setText( getResources().getString(R.string.first_page) + " " + manager.getFirstPage().getTitle()); } }
From source file:com.brq.wallet.activity.receive.ReceiveCoinsActivity.java
public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (requestCode == GET_AMOUNT_RESULT_CODE && resultCode == RESULT_OK) { // Get result from address chooser (may be null) _amount = (CurrencyValue) intent.getSerializableExtra(GetAmountActivity.AMOUNT); } else {/*from ww w . ja va2s. c o m*/ super.onActivityResult(requestCode, resultCode, intent); } }
From source file:com.androidquery.simplefeed.fragments.CommentFragment.java
@Override protected void init() { initView();//from ww w . j a va 2 s . co m Intent intent = act.getIntent(); FeedItem item = (FeedItem) intent.getSerializableExtra("item"); if (item != null) { drawContent = true; maxLines = false; item.setCommentable(true); setItem(item); } }
From source file:com.simas.vc.background_tasks.FFmpegService.java
@Override protected void onHandleIntent(Intent intent) { // Show notification String[] args = intent.getStringArrayExtra(ARG_EXEC_ARGS); File output = (File) intent.getSerializableExtra(ARG_OUTPUT_FILE); File progress = (File) intent.getSerializableExtra(ARG_PROGRESS_FILE); int duration = intent.getIntExtra(ARG_OUTPUT_DURATION, 0); // Launch progress notifier final ProgressNotifier notifier = new ProgressNotifier(duration, output, progress); Utils.runOnUiThread(new Runnable() { @Override/*from w ww . j av a 2 s. c om*/ public void run() { // AsyncTasks should be executed on the UI thread notifier.execute(); } }); // Launch the process itself final int ffmpegResult = FFmpeg.cFFmpeg(args); // Notifier cancelling must be run on the UI thread too, so it doesn't overlap the execution Utils.runOnUiThread(new Runnable() { @Override public void run() { notifier.ffmpegCancel(ffmpegResult); } }); }
From source file:edu.ucsb.cs.cs185.inspirante.collections.CardsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == ImagePicker.RESULT_CODE_ITEMS) { if (data != null && requestCode == IMAGE_PICKER) { ArrayList<ImageItem> images = (ArrayList<ImageItem>) data .getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS); ItemCards itemCards = ItemCards.getInstance(getContext()); itemCards.addNewCardFromImages(images); Intent intent = new Intent(getActivity(), EditTabsActivity.class); intent.putExtra("CARD_INDEX", 0); startActivity(intent);/*from w w w . j av a 2 s. c om*/ } else { Toast.makeText(getActivity(), "No picture selected", Toast.LENGTH_SHORT).show(); } } }
From source file:io.barracks.ota.client.helper.UpdateCheckHelper.java
/** * {@inheritDoc}// w ww .j a v a 2s. co m */ @Override public void onReceive(Context context, Intent intent) { switch (intent.getAction()) { case UpdateCheckService.ACTION_CHECK: if (callback.hashCode() == intent.getIntExtra(UpdateCheckService.EXTRA_CALLBACK, 0)) { if (intent.hasCategory(UpdateCheckService.UPDATE_REQUEST_ERROR)) { callback.onUpdateRequestError( (UpdateDetailsRequest) intent.getParcelableExtra(UpdateCheckService.EXTRA_REQUEST), (Throwable) intent.getSerializableExtra(UpdateCheckService.EXTRA_EXCEPTION)); } else if (intent.hasCategory(UpdateCheckService.UPDATE_AVAILABLE)) { callback.onUpdateAvailable( (UpdateDetailsRequest) intent.getParcelableExtra(UpdateCheckService.EXTRA_REQUEST), (UpdateDetails) intent.getParcelableExtra(UpdateCheckService.EXTRA_UPDATE_DETAILS)); } else if (intent.hasCategory(UpdateCheckService.UPDATE_UNAVAILABLE)) { callback.onUpdateUnavailable( (UpdateDetailsRequest) intent.getParcelableExtra(UpdateCheckService.EXTRA_REQUEST)); } } break; } }