List of usage examples for android.content Intent getSerializableExtra
public Serializable getSerializableExtra(String name)
From source file:org.totschnig.myexpenses.activity.ProtectedFragmentActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (requestCode == ProtectionDelegate.CONTRIB_REQUEST && intent != null) { if (resultCode == RESULT_OK) { ((ContribIFace) this).contribFeatureCalled( (ContribFeature) intent.getSerializableExtra(ContribInfoDialogActivity.KEY_FEATURE), intent.getSerializableExtra(ContribInfoDialogActivity.KEY_TAG)); } else if (resultCode == RESULT_CANCELED) { ((ContribIFace) this).contribFeatureNotCalled( (ContribFeature) intent.getSerializableExtra(ContribInfoDialogActivity.KEY_FEATURE)); }//from w w w. ja v a 2 s.co m } }
From source file:com.bufarini.reminders.AlarmReceiver.java
private void showNotification(Context context, Intent intent) { Intent snoozeIntent = new Intent(context, NotificationActivity.class); snoozeIntent.putExtras(intent.getExtras()); snoozeIntent.putExtra("notificaton action", "snooze"); PendingIntent snoozePendingIntent = PendingIntent.getActivity(context, 0, snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent doneIntent = new Intent(context, NotificationActivity.class); doneIntent.putExtras(intent.getExtras()); doneIntent.putExtra("notificaton action", "done"); doneIntent.putExtra("task", intent.getSerializableExtra("task")); PendingIntent donePendingIntent = PendingIntent.getActivity(context, 1, doneIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent resultIntent = new Intent(context, Reminders.class); resultIntent.putExtra("action", "view task"); resultIntent.putExtra("task", intent.getSerializableExtra("task")); resultIntent.setFlags(/*w w w . j av a 2 s .c om*/ Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context).setAutoCancel(true) .setSmallIcon(R.drawable.ic_action_alarms) .setContentTitle(context.getResources().getString(R.string.alarmPopupTitle1)) .setContentIntent(resultPendingIntent) .addAction(R.drawable.ic_action_alarms, "Snooze", snoozePendingIntent) .addAction(R.drawable.ic_action_done, "Done", donePendingIntent) .setContentText(intent.getExtras().getString(NotificationUtils.TITLE)); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); int notificationId = NotificationUtils.getNotificationId(intent.getExtras().getLong(NotificationUtils.ID)); notificationManager.notify(notificationId, builder.build()); }
From source file:com.grarak.kerneladiutor.fragments.tools.customcontrols.CustomControlsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (data != null) { if (requestCode == 0) { HashMap<String, Object> results = (HashMap<String, Object>) data .getSerializableExtra(CustomControlsActivity.RESULT_INTENT); updateControls(results);/*from ww w. j a v a 2 s. c o m*/ } else if (requestCode == 1) { importing(data.getStringExtra(FilePickerActivity.RESULT_INTENT)); } } }
From source file:com.zentri.otademo.OTAActivity.java
void setStatusFromIntent(TextView view, Intent intent) { Status status = (Status) intent.getSerializableExtra(ZentriOSBLEService.EXTRA_STATUS); setState(status); }
From source file:org.huxizhijian.hhcomicviewer.service.DownloadManagerService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { init();//from w w w .j a v a2s. c o m if (!mImageDownloader.isStarted()) { mImageDownloader.start(); } if (intent.getAction().equals(ACTION_START)) { // ComicChapter comicChapter = (ComicChapter) intent.getSerializableExtra("comicChapter"); if (mComicChapterDBHelper.findByChapterId(comicChapter.getChid()) == null) { // comicChapter.setSavePath(CommonUtils.getDownloadPath(this, comicChapter)); comicChapter.setDownloadStatus(Constants.DOWNLOAD_IN_QUEUE); mComicChapterDBHelper.add(comicChapter); ImageEntity entity = new ImageEntity(comicChapter.getChid(), CommonUtils.getChapterUrl(comicChapter.getCid(), comicChapter.getChid(), comicChapter.getServerId()), comicChapter.getSavePath(), comicChapter.getServerId()); Request request = new ImageDownloadRequest(entity); mImageDownloader.addRequest(request); } else { comicChapter = mComicChapterDBHelper.findByChapterId(comicChapter.getChid()); if (comicChapter.getDownloadStatus() != Constants.DOWNLOAD_FINISHED) { ImageEntity entity = new ImageEntity(comicChapter.getChid(), CommonUtils.getChapterUrl(comicChapter.getCid(), comicChapter.getChid(), comicChapter.getServerId()), comicChapter.getSavePath(), comicChapter.getServerId()); Request request = new ImageDownloadRequest(entity); mImageDownloader.addRequest(request); } } } else if (intent.getAction().equals(ACTION_START_RANGE)) { // ComicChapter comicChapter = (ComicChapter) intent.getSerializableExtra("comicChapter"); comicChapter = mComicChapterDBHelper.findByChapterId(comicChapter.getChid()); if (comicChapter.getDownloadStatus() != Constants.DOWNLOAD_FINISHED) { ImageEntity entity = new ImageEntity(comicChapter.getChid(), CommonUtils.getChapterUrl(comicChapter.getCid(), comicChapter.getChid(), comicChapter.getServerId()), comicChapter.getSavePath(), comicChapter.getServerId()); Request request = new ImageDownloadRequest(entity); mImageDownloader.addRequest(request); } } else if (intent.getAction().equals(ACTION_STOP)) { //? ComicChapter comicChapter = (ComicChapter) intent.getSerializableExtra("comicChapter"); Log.i("DownloadManagerService", "onStartCommand: stop"); ImageEntity entity = new ImageEntity(comicChapter.getChid(), CommonUtils .getChapterUrl(comicChapter.getCid(), comicChapter.getChid(), comicChapter.getServerId()), comicChapter.getSavePath(), comicChapter.getServerId()); Request request = new ImageDownloadRequest(entity); mImageDownloader.cancelRequest(request); } else if (intent.getAction().equals(ACTION_ALL_START)) { // List<ComicChapter> unFinishedChapters = mComicChapterDBHelper.findUnFinishedChapters(); if (unFinishedChapters != null) { List<Request> requestList = new ArrayList<>(); Request request; for (ComicChapter comicChapter : unFinishedChapters) { ImageEntity entity = new ImageEntity(comicChapter.getChid(), CommonUtils.getChapterUrl(comicChapter.getCid(), comicChapter.getChid(), comicChapter.getServerId()), comicChapter.getSavePath(), comicChapter.getServerId()); request = new ImageDownloadRequest(entity); requestList.add(request); } mImageDownloader.addRequest(requestList); } } else if (intent.getAction().equals(ACTION_ALL_STOP)) { //? mImageDownloader.stop(); } else if (intent.getAction().equals(ACTION_DELETE)) { // final ComicChapter comicChapter = (ComicChapter) intent.getSerializableExtra("comicChapter"); Log.i("DownloadManagerService", "onStartCommand: delete"); AppOperator.runOnThread(new Runnable() { @Override public void run() { deleteChapter(comicChapter); } }); } else if (intent.getAction().equals(ACTION_DELETE_COMIC)) { // Comic comic = (Comic) intent.getSerializableExtra("comic"); final List<ComicChapter> chapters = mComicChapterDBHelper.findByComicCid(comic.getCid()); if (chapters != null) { AppOperator.runOnThread(new Runnable() { @Override public void run() { for (ComicChapter chapter : chapters) { deleteChapter(chapter); } } }); } } return START_REDELIVER_INTENT; }
From source file:org.liberty.android.fantastischmemo.service.ConvertIntentService.java
@Override public void onHandleIntent(Intent intent) { if (!Objects.equal(intent.getAction(), ACTION_CONVERT)) { throw new IllegalArgumentException("The Action is wrong"); }/*from ww w.jav a2s . c om*/ String inputFilePath = intent.getStringExtra(EXTRA_INPUT_FILE_PATH); assert inputFilePath != null : "Input file path should not be null"; String outputFilePath = intent.getStringExtra(EXTRA_OUTPUT_FILE_PATH); assert outputFilePath != null : "Output file path should not be null"; @SuppressWarnings("unchecked") Class<Converter> conveterClass = (Class<Converter>) intent.getSerializableExtra(EXTRA_CONVERTER_CLASS); Converter converter = RoboGuice.getInjector(getApplication()).getInstance(conveterClass); // Replace the extension of the file: file.xml -> file.db String conversionFileInfo = "" + FilenameUtils.getName(inputFilePath) + " -> " + FilenameUtils.getName(outputFilePath); int notificationId = CONVERSION_PROGRESS_NOTIFICATION_ID_BASE + inputFilePath.hashCode(); showInProgressNotification(notificationId, conversionFileInfo); try { converter.convert(inputFilePath, outputFilePath); showSuccessNotification(notificationId, outputFilePath); } catch (Exception e) { Ln.e(e, "Error while converting"); showFailureNotification(notificationId, conversionFileInfo, e); } }
From source file:org.rm3l.ddwrt.tiles.services.vpn.OpenVPNClientTile.java
@Override public void onResultCode(int resultCode, Intent data) { switch (resultCode) { case Activity.RESULT_OK: final NVRAMInfo newNvramInfoData = (NVRAMInfo) data.getSerializableExtra(OPENVPNCL_NVRAMINFO); if (newNvramInfoData == null || newNvramInfoData.isEmpty()) { Utils.displayMessage(mParentFragmentActivity, "No change", Style.INFO); break; }//from w ww . j a v a 2 s .c o m final Bundle token = new Bundle(); token.putString(DDWRTMainActivity.ROUTER_ACTION, RouterAction.SET_NVRAM_VARIABLES.toString()); token.putSerializable(OPENVPNCL_NVRAMINFO, newNvramInfoData); new UndoBarController.UndoBar(mParentFragmentActivity) .message("OpenVPN Client Settings will be updated").listener(this).token(token).show(); break; default: //Ignored break; } }
From source file:im.neon.activity.VectorMediasViewerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (CommonActivityUtils.shouldRestartApp(this)) { Log.d(LOG_TAG, "onCreate : restart the application"); CommonActivityUtils.restartApp(this); return;//from w w w .j a v a 2s .c om } if (CommonActivityUtils.isGoingToSplash(this)) { Log.d(LOG_TAG, "onCreate : Going to splash screen"); return; } String matrixId = null; Intent intent = getIntent(); if (intent.hasExtra(EXTRA_MATRIX_ID)) { matrixId = intent.getStringExtra(EXTRA_MATRIX_ID); } mSession = Matrix.getInstance(getApplicationContext()).getSession(matrixId); if (mSession == null) { finish(); return; } mxMediasCache = mSession.getMediasCache(); mMediasList = (List<SlidableMediaInfo>) intent.getSerializableExtra(KEY_INFO_LIST); setContentView(R.layout.activity_vector_medias_viewer); mViewPager = (ViewPager) findViewById(R.id.view_pager); int position = intent.getIntExtra(KEY_INFO_LIST_INDEX, 0); int maxImageWidth = intent.getIntExtra(KEY_THUMBNAIL_WIDTH, 0); int maxImageHeight = intent.getIntExtra(VectorMediasViewerActivity.KEY_THUMBNAIL_HEIGHT, 0); mAdapter = new VectorMediasViewerAdapter(this, mSession, mxMediasCache, mMediasList, maxImageWidth, maxImageHeight); mAdapter.autoPlayItemAt(position); mViewPager.setAdapter(mAdapter); mViewPager.setCurrentItem(position); mViewPager.setPageTransformer(true, new DepthPageTransformer()); if (null != VectorMediasViewerActivity.this.getSupportActionBar()) { VectorMediasViewerActivity.this.getSupportActionBar().setTitle(mMediasList.get(position).mFileName); } mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { if (null != VectorMediasViewerActivity.this.getSupportActionBar()) { VectorMediasViewerActivity.this.getSupportActionBar() .setTitle(mMediasList.get(position).mFileName); } } @Override public void onPageScrollStateChanged(int state) { } }); }
From source file:com.cmput301w17t07.moody.EditMoodActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); UserController userController = new UserController(); userName = userController.readUsername(EditMoodActivity.this).toString(); setContentView(R.layout.activity_edit_mood); setUpMenuBar(this); // get the mood object that was selected Intent intent = getIntent(); editMood = (Mood) intent.getSerializableExtra("editMood"); date = editMood.getDate();//from w w w . j ava 2 s.c o m bitmapImage = (Bitmap) intent.getParcelableExtra("bitmapback"); editBitmapImage = bitmapImage; deletedPic = (int) intent.getExtras().getInt("bitmapdelete"); latitude = editMood.getLatitude(); longitude = editMood.getLongitude(); image = (ImageView) findViewById(R.id.editImageView); final TextView location = (TextView) findViewById(R.id.locationText); address = editMood.getDisplayLocation(); location.setText(address); if (latitude == 0 && longitude == 0) { location1 = null; } displayAttributes(); if (deletedPic == 1) { image.setImageBitmap(null); } //set up the button and imageButton ImageButton editLocation = (ImageButton) findViewById(R.id.location); editLocation.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { locationText = (TextView) findViewById(R.id.locationText); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); //check available tools List<String> locationList = locationManager.getProviders(true); if (locationList.contains(LocationManager.GPS_PROVIDER)) { provider = LocationManager.GPS_PROVIDER; } else if (locationList.contains(LocationManager.NETWORK_PROVIDER)) { provider = LocationManager.NETWORK_PROVIDER; } else { Toast.makeText(getApplicationContext(), "Please check your permissions", Toast.LENGTH_LONG) .show(); } //check the permission if (ActivityCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling Toast.makeText(getApplicationContext(), "Getting location failed, Please check the application permissions", Toast.LENGTH_SHORT) .show(); return; } location1 = locationManager.getLastKnownLocation(provider); if (location1 == null) { latitude = 0; longitude = 0; } else { latitude = location1.getLatitude(); longitude = location1.getLongitude(); } //get the location name by latitude and longitude Geocoder gcd = new Geocoder(EditMoodActivity.this, Locale.getDefault()); try { List<Address> addresses = gcd.getFromLocation(latitude, longitude, 1); if (addresses.size() > 0) address = " " + addresses.get(0).getFeatureName() + " " + addresses.get(0).getThoroughfare() + ", " + addresses.get(0).getLocality() + ", " + addresses.get(0).getAdminArea() + ", " + addresses.get(0).getCountryCode(); location.setText(address); } catch (Exception e) { e.printStackTrace(); } final ImageButton deleteLocation = (ImageButton) findViewById(R.id.deleteLocation); deleteLocation.setVisibility(View.VISIBLE); deleteLocation.setEnabled(true); } }); editLocation.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { moodMessage_text = Description.getText().toString(); editMood.setMoodMessage(moodMessage_text); editMood.setDate(date); Intent editLocation = new Intent(EditMoodActivity.this, EditLocation.class); editLocation.putExtra("EditMood", editMood); editLocation.putExtra("bitmap", compress(editBitmapImage)); startActivity(editLocation); return true; } }); final ImageButton deleteLocation = (ImageButton) findViewById(R.id.deleteLocation); deleteLocation.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { location1 = null; locationText = (TextView) findViewById(R.id.locationText); address = null; locationText.setText(address); latitude = 0; longitude = 0; deleteLocation.setVisibility(View.INVISIBLE); deleteLocation.setEnabled(false); } }); ImageButton editCameraButton = (ImageButton) findViewById(R.id.editCamera); editCameraButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 1); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), EditMoodActivity.class); startActivity(intent); } } }); editCameraButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { try { Intent intent = new Intent("android.intent.action.PICK"); intent.setType("image/*"); startActivityForResult(intent, 0); } catch (Exception e) { Intent intent = new Intent(getApplicationContext(), EditMoodActivity.class); startActivity(intent); } return true; } }); ImageButton PickerButton = (ImageButton) findViewById(R.id.EditDate); PickerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { innit(); TimeDialog.show(); } }); Button submitButton = (Button) findViewById(R.id.button5); submitButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { moodMessage_text = Description.getText().toString(); MoodController moodController = new MoodController(); editBitmapImage = bitmapImage; AchievementManager.initManager(EditMoodActivity.this); AchievementController achievementController = new AchievementController(); achievements = achievementController.getAchievements(); achievements.firstTimeEditFlag = 1; achievementController.saveAchievements(); if (!moodController.editMood(EmotionText, userName, moodMessage_text, latitude, longitude, editBitmapImage, SocialSituation, date, address, editMood, EditMoodActivity.this)) { Toast.makeText(EditMoodActivity.this, "Mood message length is too long. Please try again", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(EditMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } }); // TODO button needs only display when image present in Mood final ImageButton deletePicture = (ImageButton) findViewById(R.id.deletePicture); if (editBitmapImage == null || deletedPic == 1) { deletePicture.setVisibility(View.INVISIBLE); deletePicture.setEnabled(false); } deletePicture.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { bitmapImage = null; editBitmapImage = null; image.setImageDrawable(null); deletePicture.setVisibility(View.INVISIBLE); deletePicture.setEnabled(false); } }); }
From source file:com.retroteam.studio.retrostudio.MeasureEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get the note positions from the intent Intent intent = getIntent(); theproject = (Project) intent.getSerializableExtra("Project"); String message = intent.getStringExtra(EditorLandscape.MEASURE_INFO); String titlebar = intent.getStringExtra(EditorLandscape.MEASURE_TITLE); trackNum = intent.getIntExtra(EditorLandscape.MEASURE_TRACK, 0); measureNum = intent.getIntExtra(EditorLandscape.MEASURE, 0); measureID = intent.getIntExtra("measureID", 0); guiSNAPFromIntent = intent.getIntExtra("guiSNAP", 0); filledNotesFromIntent = (ArrayList<int[]>) intent.getSerializableExtra("filledNotes"); TS_BEATS = intent.getIntExtra("tsBeats", 4); TS_NOTES = intent.getIntExtra("tsNotes", 4); //setContentView(R.layout.activity_trackedit); setContentView(R.layout.activity_measureedit); setupActionBar(titlebar); //cannot use this if we have no action bar //final View controlsView = findViewById(R.id.fullscreen_content_controls); final View contentView = findViewById(R.id.fullscreen_content); //toggleHideyBar(); //start immersive mode // show a toast with the info //Toast.makeText(this, "REALLY editing measure " + trackNum + "," + measureNum, Toast.LENGTH_SHORT).show(); final CharSequence[] guisnapopts = { "4", "8", "16", "32" }; if (filledNotesFromIntent.size() > 0) { filledNotes = filledNotesFromIntent; }/*from ww w .j a v a 2 s. c om*/ if (guiSNAPFromIntent == 0) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose Note Precision").setItems(guisnapopts, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // The 'which' argument contains the index position // of the selected item guiSNAP = Integer.parseInt(guisnapopts[which].toString()); drawGrid(); } }); AlertDialog dialog = builder.create(); dialog.show(); } else { guiSNAP = guiSNAPFromIntent; drawGrid(); } //thismeasure.length() // //dynamically fill up the first row of every line with notes // LinearLayout notecontainer = (LinearLayout) findViewById(R.id.notecontainer); // //HorizontalScrollView notecontainer = (HorizontalScrollView) findViewById(R.id.content); // // for (int i = 0; i < notes.length; i++) { // TextView note = new TextView(getApplicationContext()); // // use non-deprecated function if 5.0 or above // note.setId(i); // note.setGravity(1); // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // note.setBackground(getDrawable(R.drawable.note_icon_small_alphad)); // }else { // Resources resources = getResources(); // note.setBackground(resources.getDrawable(R.drawable.note_icon_small_alphad)); // } // note.setText(notes[i]); // note.setTextSize(50); // note.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View view) { // //our implementation of "tap this to play the noise it makes goes here" // //this.image1.playSound(); // MediaPlayer mp = MediaPlayer.create(EditorLandscape.this, R.raw.beep); // mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { // // @Override // public void onCompletion(MediaPlayer mp) { // mp.release(); // } // // }); // mp.start(); // } // }); // notecontainer.addView(note); // } }