List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.markupartist.sthlmtraveling.PlannerFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_POINT_ON_MAP_START: if (resultCode == Activity.RESULT_CANCELED) { Log.d(TAG, "action canceled"); } else {// w w w. j av a 2 s .com mStartPoint = data.getParcelableExtra(PointOnMapActivity.EXTRA_STOP); mStartPointAutoComplete.setText(getText(R.string.point_on_map)); // mStartPointAutoComplete.setText(mStartPoint.getName()); Log.d(TAG, "Got Stop " + mStartPoint); } break; case REQUEST_CODE_POINT_ON_MAP_END: if (resultCode == Activity.RESULT_CANCELED) { Log.d(TAG, "action canceled"); } else { mEndPoint = data.getParcelableExtra(PointOnMapActivity.EXTRA_STOP); mEndPointAutoComplete.setText(getText(R.string.point_on_map)); // mEndPointAutoComplete.setText(mEndPoint.getName()); Log.d(TAG, "Got Stop " + mEndPoint); } break; } }
From source file:it.feio.android.omninotes.SettingsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case SPRINGPAD_IMPORT: Uri filesUri = intent.getData(); String path = FileHelper.getPath(getActivity(), filesUri); // An IntentService will be launched to accomplish the import task Intent service = new Intent(getActivity(), DataBackupIntentService.class); service.setAction(DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD); service.putExtra(DataBackupIntentService.EXTRA_SPRINGPAD_BACKUP, path); getActivity().startService(service); break; case RINGTONE_REQUEST_CODE: Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String notificationSound = uri == null ? null : uri.toString(); prefs.edit().putString("settings_notification_ringtone", notificationSound).apply(); break; }/* w w w.j av a 2 s.c o m*/ } }
From source file:com.nbplus.vbroadlauncher.BroadcastPushReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (intent == null) { return;//w ww .ja v a2 s .co m } Intent pi; String action = intent.getAction(); if (PushConstants.ACTION_PUSH_STATUS_CHANGED.equals(action)) { LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } else if (PushConstants.ACTION_PUSH_MESSAGE_RECEIVED.equals(action)) { Log.d(TAG, "Receive.. broadcast ACTION_PUSH_MESSAGE_RECEIVED from push service. re-direct to activity!!!"); //TODO: iot ?. // int i = 0; // if (i == 0) { // return; // } PushMessageData data = null; try { data = (PushMessageData) intent.getParcelableExtra(PushConstants.EXTRA_PUSH_MESSAGE_DATA); if (data == null || StringUtils.isEmptyString(data.getPayload())) { Log.d(TAG, "empty push message string !!"); return; } } catch (Exception e) { e.printStackTrace(); return; } PushPayloadData payloadData = null; try { Gson gson = new GsonBuilder().create(); payloadData = gson.fromJson(data.getPayload(), new TypeToken<PushPayloadData>() { }.getType()); } catch (Exception e) { e.printStackTrace(); } if (payloadData == null) { Log.d(TAG, "empty push message data !!"); return; } String type = payloadData.getServiceType(); Log.d(TAG, "HANDLER_MESSAGE_PUSH_MESAGE_RECEIVED received type = " + type + ", messageId = " + payloadData.getMessageId()); payloadData.setAlertMessage(data.getAlert()); switch (type) { // case Constants.PUSH_PAYLOAD_TYPE_REALTIME_BROADCAST: case Constants.PUSH_PAYLOAD_TYPE_NORMAL_BROADCAST: case Constants.PUSH_PAYLOAD_TYPE_TEXT_BROADCAST: TelephonyManager telephonyManager = (TelephonyManager) context .getSystemService(Context.TELEPHONY_SERVICE); int callState = telephonyManager.getCallState(); boolean isOutdoor = LauncherSettings.getInstance(context).isOutdoorMode(); playNotificationAlarm(context, R.string.notification_broadcast_push); if (isOutdoor || callState == TelephonyManager.CALL_STATE_OFFHOOK) { // ? ? ?. Log.d(TAG, "Broadcast notification.. isOutdoor mode... "); pi = new Intent(); pi.setAction(action); pi.putExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, intent.getIntExtra( PushConstants.EXTRA_PUSH_STATUS_VALUE, PushConstants.PUSH_STATUS_VALUE_DISCONNECTED)); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); LocalBroadcastManager.getInstance(context).sendBroadcast(pi); return; } if (Constants.OPEN_BETA_PHONE) { String activePackageName = PackageUtils.getActivePackage(context); if (activePackageName != null && !StringUtils.isEmptyString(activePackageName)) { if (Constants.VBROAD_SEND_APP_PACKAGE.equals(activePackageName)) { Log.d(TAG, Constants.VBROAD_SEND_APP_PACKAGE + " is top running application...."); pi = new Intent(); pi.setAction(action); pi.putExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, intent.getIntExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, PushConstants.PUSH_STATUS_VALUE_DISCONNECTED)); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); LocalBroadcastManager.getInstance(context).sendBroadcast(pi); return; } } } // ?? ?. ? Domain url ?? . if (PackageUtils.isActivePackage(context, Constants.GOOGLE_CHROME_PACKAGE_NAME)) { Log.d(TAG, "chrome browser is active...."); // get the last visited URL from the Browser.BOOKMARKS_URI database String url = ""; Uri chromeUri = Uri.parse("content://com.android.chrome.browser/bookmarks"); Cursor cur = context.getContentResolver().query(chromeUri/*Browser.BOOKMARKS_URI*/, new String[] { Browser.BookmarkColumns.URL }, null, null, Browser.BookmarkColumns.DATE + " DESC"); if (cur != null && cur.getCount() > 0) { cur.moveToFirst(); url = cur.getString(cur.getColumnIndex(Browser.BookmarkColumns.URL)); cur.close(); } else { if (cur != null) { cur.close(); } } Log.d(TAG, "Last activated url = " + url); if (!StringUtils.isEmptyString(url) && (url.startsWith(Constants.VBROAD_HTTP_DOMAIN) || url.startsWith(Constants.VBROAD_HTTPS_DOMAIN))) { Log.w(TAG, ">> Village broadcast is running... do not show!!!!"); pi = new Intent(); pi.setAction(action); pi.putExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, intent.getIntExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, PushConstants.PUSH_STATUS_VALUE_DISCONNECTED)); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); LocalBroadcastManager.getInstance(context).sendBroadcast(pi); return; } } // android version check. if (Constants.PUSH_PAYLOAD_TYPE_REALTIME_BROADCAST.equals(type) || Constants.PUSH_PAYLOAD_TYPE_NORMAL_BROADCAST.equals(type)) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Log.d(TAG, ">> This device version code = " + Build.VERSION.SDK_INT + ", not supported version !!"); Toast.makeText(context, R.string.notification_broadcast_not_support, Toast.LENGTH_SHORT); pi = new Intent(); pi.setAction(action); pi.putExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, intent.getIntExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, PushConstants.PUSH_STATUS_VALUE_DISCONNECTED)); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); LocalBroadcastManager.getInstance(context).sendBroadcast(pi); break; } } /*boolean useServiceChatHead = false; if (useServiceChatHead) { i = new Intent(context, RealtimeBroadcastProxyActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setAction(action); i.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); context.startActivity(i); } else*/ String playingType = LauncherSettings.getInstance(context).getCurrentPlayingBroadcastType(); if (StringUtils.isEmptyString(playingType) || !Constants.PUSH_PAYLOAD_TYPE_REALTIME_BROADCAST.equals(playingType)) { // ??? ... ? . ??? pi = new Intent(context, RealtimeBroadcastActivity.class); pi.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pi.setAction(action); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_INDEX, System.currentTimeMillis()); Log.d(TAG, "1. sendBroadcast() >> ACTION_PUSH_MESSAGE_RECEIVED : idx = " + pi.getLongExtra(Constants.EXTRA_BROADCAST_PAYLOAD_INDEX, -1)); // ? ms ? ?? ? ? ? ???? // broadcast ? . // ?? ?? ??. //LocalBroadcastManager.getInstance(context).sendBroadcast(pi); try { //Thread.sleep(30); context.startActivity(pi); } catch (Exception e) { e.printStackTrace(); } } else { // ?? ? ??... ? ?.. ? . if (Constants.PUSH_PAYLOAD_TYPE_REALTIME_BROADCAST.equals(playingType) && Constants.PUSH_PAYLOAD_TYPE_REALTIME_BROADCAST.equals(type)) { pi = new Intent(context, RealtimeBroadcastActivity.class); pi.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); pi.setAction(action); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_INDEX, System.currentTimeMillis()); Log.d(TAG, "2. sendBroadcast() >> ACTION_PUSH_MESSAGE_RECEIVED : idx = " + pi.getLongExtra(Constants.EXTRA_BROADCAST_PAYLOAD_INDEX, -1)); // ? ms ? ?? ? ? ? ???? // broadcast ? . // ?? ?? ??. //LocalBroadcastManager.getInstance(context).sendBroadcast(pi); try { //Thread.sleep(30); context.startActivity(pi); } catch (Exception e) { e.printStackTrace(); } } else { // ? ? ? ??. Log.d(TAG, "? ? ? ??."); Toast.makeText(context, payloadData.getAlertMessage(), Toast.LENGTH_SHORT).show(); } } break; // case Constants.PUSH_PAYLOAD_TYPE_EMERGENCY_CALL: break; // case Constants.PUSH_PAYLOAD_TYPE_INHABITANTS_POLL: // ? case Constants.PUSH_PAYLOAD_TYPE_COOPERATIVE_BUYING: int strId = Constants.PUSH_PAYLOAD_TYPE_INHABITANTS_POLL.equals(payloadData.getServiceType()) ? R.string.notification_inhabitant_push : R.string.notification_cooperative_buying_push; playNotificationAlarm(context, strId); pi = new Intent(); pi.setAction(action); pi.putExtra(PushConstants.EXTRA_PUSH_STATUS_VALUE, intent.getIntExtra( PushConstants.EXTRA_PUSH_STATUS_VALUE, PushConstants.PUSH_STATUS_VALUE_DISCONNECTED)); pi.putExtra(Constants.EXTRA_BROADCAST_PAYLOAD_DATA, payloadData); Log.d(TAG, "3. sendBroadcast() >> ACTION_PUSH_MESSAGE_RECEIVED : idx = " + 0); LocalBroadcastManager.getInstance(context).sendBroadcast(pi); break; // IOT DEVICE ( ) case Constants.PUSH_PAYLOAD_TYPE_IOT_DEVICE_CONTROL: Log.d(TAG, "startService >> ACTION_SEND_IOT_COMMAND"); IoTInterface.getInstance().controlDevice(payloadData.getIotControlDeviceId(), payloadData.getMessage()); break; // PUSH_PAYLOAD_TYPE_PUSH_NOTIFICATION case Constants.PUSH_PAYLOAD_TYPE_PUSH_NOTIFICATION: // ?... // pi = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(payloadData.getMessage())); // showNotification(context, Constants.SYSTEM_ADMIN_NOTIFICATION_ID, PackageUtils.getApplicationName(context), payloadData.getAlertMessage(), null, pi); // bigText showNotification(context, Constants.SYSTEM_ADMIN_NOTIFICATION_ID, PackageUtils.getApplicationName(context), payloadData.getAlertMessage(), PackageUtils.getApplicationName(context), payloadData.getMessage(), null, null, null); break; // IOT DEVICE ( ) case Constants.PUSH_PAYLOAD_TYPE_FIND_PASSWORD: pi = new Intent(Intent.ACTION_VIEW).setData(Uri.parse(payloadData.getMessage())); showNotification(context, Constants.PW_FIND_NOTIFICATION_ID, PackageUtils.getApplicationName(context), payloadData.getAlertMessage(), null, pi); break; default: Log.d(TAG, "Unknown push payload type !!!"); break; } } }
From source file:com.dycody.android.idealnote.SettingsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case SPRINGPAD_IMPORT: Uri filesUri = intent.getData(); String path = FileHelper.getPath(getActivity(), filesUri); // An IntentService will be launched to accomplish the import task Intent service = new Intent(getActivity(), DataBackupIntentService.class); service.setAction(DataBackupIntentService.ACTION_DATA_IMPORT_SPRINGPAD); service.putExtra(DataBackupIntentService.EXTRA_SPRINGPAD_BACKUP, path); getActivity().startService(service); break; case RINGTONE_REQUEST_CODE: Uri uri = intent.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI); String notificationSound = uri == null ? null : uri.toString(); prefs.edit().putString("settings_notification_ringtone", notificationSound).apply(); break; default:/*from w w w . j a v a2 s. c om*/ Log.e(Constants.TAG, "Wrong element choosen: " + requestCode); } } }
From source file:com.daiv.android.twitter.ui.compose.Compose.java
void handleSendImage(Intent intent) { Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { //String filePath = IOUtils.getPath(imageUri, context); try {/*from w ww . j av a2 s .c om*/ attachImage[imagesAttached].setImageBitmap(getThumbnail(imageUri)); attachImage[imagesAttached].setVisibility(View.VISIBLE); attachedUri[imagesAttached] = imageUri.toString(); imagesAttached++; //numberAttached.setText(imagesAttached + " " + getResources().getString(R.string.attached_images)); //numberAttached.setVisibility(View.VISIBLE); } catch (FileNotFoundException e) { Toast.makeText(context, getResources().getString(R.string.error), Toast.LENGTH_SHORT); //numberAttached.setText(""); //numberAttached.setVisibility(View.GONE); } catch (IOException e) { Toast.makeText(context, getResources().getString(R.string.error), Toast.LENGTH_SHORT); //numberAttached.setText(""); //numberAttached.setVisibility(View.GONE); } } }
From source file:com.orangelabs.rcs.ri.extension.messaging.MessagingSessionView.java
private void initialiseMessagingSession(Intent intent) { MultimediaSessionService sessionApi = mCnxManager.getMultimediaSessionApi(); try {/*w ww . j a v a2 s.c om*/ MultimediaSessionServiceConfiguration config = sessionApi.getConfiguration(); if (LogUtils.isActive) { Log.d(LOGTAG, "MessageMaxLength: ".concat(Integer.toString(config.getMessageMaxLength()))); } int mode = intent.getIntExtra(MessagingSessionView.EXTRA_MODE, -1); if (mode == MessagingSessionView.MODE_OUTGOING) { // Outgoing session // Check if the service is available if (!sessionApi.isServiceRegistered()) { Utils.showMessageAndExit(this, getString(R.string.label_service_not_available), mExitOnce); return; } // Get remote contact mContact = intent.getParcelableExtra(MessagingSessionView.EXTRA_CONTACT); // Initiate session startSession(); } else if (mode == MessagingSessionView.MODE_OPEN) { // Open an existing session // Incoming session mSessionId = intent.getStringExtra(MessagingSessionView.EXTRA_SESSION_ID); // Get the session mSession = sessionApi.getMessagingSession(mSessionId); if (mSession == null) { // Session not found or expired Utils.showMessageAndExit(this, getString(R.string.label_session_has_expired), mExitOnce); return; } // Get remote contact mContact = mSession.getRemoteContact(); } else { // Incoming session from its Intent mSessionId = intent.getStringExtra(MultimediaMessagingSessionIntent.EXTRA_SESSION_ID); // Get the session mSession = sessionApi.getMessagingSession(mSessionId); if (mSession == null) { // Session not found or expired Utils.showMessageAndExit(this, getString(R.string.label_session_has_expired), mExitOnce); return; } // Get remote contact mContact = mSession.getRemoteContact(); String from = RcsDisplayName.getInstance(this).getDisplayName(mContact); // Manual accept AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.title_messaging_session); builder.setMessage(getString(R.string.label_mm_from_id, from, mServiceId)); builder.setCancelable(false); builder.setIcon(R.drawable.ri_notif_mm_session_icon); builder.setPositiveButton(getString(R.string.label_accept), acceptBtnListener); builder.setNegativeButton(getString(R.string.label_decline), declineBtnListener); builder.show(); } // Display session info TextView featureTagEdit = (TextView) findViewById(R.id.feature_tag); featureTagEdit.setText(mServiceId); String from = RcsDisplayName.getInstance(this).getDisplayName(mContact); TextView contactEdit = (TextView) findViewById(R.id.contact); contactEdit.setText(from); Button sendBtn = (Button) findViewById(R.id.send_btn); if (mSession != null) { sendBtn.setEnabled(true); } else { sendBtn.setEnabled(false); } } catch (RcsServiceException e) { Utils.showMessageAndExit(this, getString(R.string.label_api_failed), mExitOnce, e); } }
From source file:com.klinker.android.twitter.activities.compose.Compose.java
void handleSendImage(Intent intent) { Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { //String filePath = IOUtils.getPath(imageUri, context); try {//from ww w.jav a2s . c om attachImage[imagesAttached].setImageBitmap(getThumbnail(imageUri)); attachImage[imagesAttached].setVisibility(View.VISIBLE); attachedUri[imagesAttached] = imageUri.toString(); imagesAttached++; //numberAttached.setText(imagesAttached + " " + getResources().getString(R.string.attached_images)); //numberAttached.setVisibility(View.VISIBLE); } catch (FileNotFoundException e) { Toast.makeText(context, getResources().getString(R.string.error), Toast.LENGTH_SHORT); //numberAttached.setText(""); //numberAttached.setVisibility(View.GONE); } catch (IOException e) { Toast.makeText(context, getResources().getString(R.string.error), Toast.LENGTH_SHORT); //numberAttached.setText(""); //numberAttached.setVisibility(View.GONE); } } }
From source file:com.cmput301w17t07.moody.CreateMoodActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_create_mood); UserController userController = new UserController(); userName = userController.readUsername(CreateMoodActivity.this).toString(); setUpMenuBar(this); location = null;//from w ww. j a v a2 s .c o m date = new Date(); Intent intent = getIntent(); locationText = (TextView) findViewById(R.id.locationText); Description = (EditText) findViewById(R.id.Description); mImageView = (ImageView) findViewById(R.id.editImageView); //try to get picklocation, if it is equal to 1 that means, user just back from map not //other activities try { pickLocation = (int) intent.getExtras().getInt("pickLocation"); } catch (Exception e) { e.printStackTrace(); } if (pickLocation == 1) { tempMood = (Mood) intent.getSerializableExtra("editMood"); bitmap = (Bitmap) intent.getParcelableExtra("bitmapback"); latitude = tempMood.getLatitude(); longitude = tempMood.getLongitude(); address = tempMood.getDisplayLocation(); locationText.setText(address); Description.setText(tempMood.getMoodMessage()); mImageView.setImageBitmap(bitmap); date = tempMood.getDate(); displayAttributes(); } /** * Spinner dropdown logic taken from http://stackoverflow.com/questions/13377361/how-to-create-a-drop-down-list <br> * Author: Nicolas Tyler, 2013/07/15 8:47 <br> * taken by Xin Huang 2017/03/10 <br> */ //Spinner for emotion and socialsituatuion if (pickLocation == 0) { Spinner dropdown = (Spinner) findViewById(R.id.Emotion); String[] items = new String[] { "anger", "confusion", "disgust", "fear", "happiness", "sadness", "shame", "surprise" }; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items); dropdown.setAdapter(adapter); dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { EmotionText = parent.getItemAtPosition(position).toString(); } @Override public void onNothingSelected(AdapterView<?> parent) { Toast.makeText(CreateMoodActivity.this, "Please pick a feeling!", Toast.LENGTH_SHORT).show(); } }); Spinner dropdown_SocialSituation = (Spinner) findViewById(R.id.SocialSituation); String[] item_SocialSituation = new String[] { "", "alone", "with one other person", "with two people", "with several people", "with a crowd" }; ArrayAdapter<String> adapter_SocialSituation = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, item_SocialSituation); dropdown_SocialSituation.setAdapter(adapter_SocialSituation); dropdown_SocialSituation.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { SocialSituation = parent.getItemAtPosition(position).toString(); TextView sizeView = (TextView) findViewById(R.id.SocialText); sizeView.setText(" " + SocialSituation); } @Override public void onNothingSelected(AdapterView<?> parent) { } }); } ImageButton chooseButton = (ImageButton) findViewById(R.id.Camera); ImageButton locationButton = (ImageButton) findViewById(R.id.location); ImageButton PickerButton = (ImageButton) findViewById(R.id.Picker); //click on PickerButton, call the datetimePicker PickerButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { innit(); TimeDialog.show(); } }); chooseButton.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(), CreateMoodActivity.class); startActivity(intent); } } }); chooseButton.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(), CreateMoodActivity.class); startActivity(intent); } return true; } }); locationButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { 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 application permissions", Toast.LENGTH_LONG).show(); } //check the permission if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // TODO: Consider calling Toast.makeText(getApplicationContext(), "Get location failed, Please check the Permission", Toast.LENGTH_SHORT).show(); return; } location = locationManager.getLastKnownLocation(provider); if (location == null) { latitude = 0; longitude = 0; } else { latitude = location.getLatitude(); longitude = location.getLongitude(); } Geocoder gcd = new Geocoder(CreateMoodActivity.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(); locationText.setText(address); } catch (Exception e) { e.printStackTrace(); } } }); //pass users' changes to map, will be passed back locationButton.setOnLongClickListener(new View.OnLongClickListener() { public boolean onLongClick(View view) { int fromCreate = 123; moodMessage_text = Description.getText().toString(); tempMood = new Mood(EmotionText, userName, moodMessage_text, latitude, longitude, null, SocialSituation, date, address); Intent editLocation = new Intent(CreateMoodActivity.this, EditLocation.class); editLocation.putExtra("EditMood", tempMood); editLocation.putExtra("fromCreate", fromCreate); editLocation.putExtra("bitmap", compress(bitmap)); startActivity(editLocation); return true; } }); 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(); // --------------------------- achievements ------------------------------------- AchievementManager.initManager(CreateMoodActivity.this); AchievementController achievementController = new AchievementController(); achievements = achievementController.getAchievements(); achievements.moodCount += 1; achievementController.incrementMoodCounter(EmotionText); achievementController.saveAchievements(); // ------------------------------------------------------------------------------ if (location != null || pickLocation == 1) { //todo can remove these if/else statements that toast message too long. They could // be handled in the controller if (!MoodController.createMood(EmotionText, userName, moodMessage_text, latitude, longitude, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } else { if (!MoodController.createMood(EmotionText, userName, moodMessage_text, 0, 0, bitmap, SocialSituation, date, address, CreateMoodActivity.this)) { Toast.makeText(CreateMoodActivity.this, "Mood message length is too long. Please try again.", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(CreateMoodActivity.this, TimelineActivity.class); startActivity(intent); finish(); } } } }); }
From source file:com.binomed.showtime.android.screen.movie.CineShowTimeMovieFragment.java
@Override public void onResume() { super.onResume(); Intent intent = interaction.getIntentMovie(); String movieId = null;//from w w w .j av a 2 s .c o m String theaterId = null; boolean fromWidget = intent.getBooleanExtra(ParamIntent.ACTIVITY_MOVIE_FROM_WIDGET, false); String near = intent.getStringExtra(ParamIntent.ACTIVITY_MOVIE_NEAR); Log.i(TAG, "From Widget : " + fromWidget); MovieBean movie = null; TheaterBean theater = null; // if (fromWidget) { // // Object[] currentMovie = extractCurrentMovie(); // if (currentMovie != null) { // theater = (TheaterBean) currentMovie[0]; // movie = (MovieBean) currentMovie[1]; // } // } else { movieId = intent.getStringExtra(ParamIntent.MOVIE_ID); movie = intent.getParcelableExtra(ParamIntent.MOVIE); theaterId = intent.getStringExtra(ParamIntent.THEATER_ID); theater = intent.getParcelableExtra(ParamIntent.THEATER); double latitude = intent.getDoubleExtra(ParamIntent.ACTIVITY_MOVIE_LATITUDE, -1); double longitude = intent.getDoubleExtra(ParamIntent.ACTIVITY_MOVIE_LONGITUDE, -1); if ((latitude != -1) && (longitude != -1)) { Location gpsLocation = new Location("GPS"); //$NON-NLS-1$ gpsLocation.setLatitude(latitude); gpsLocation.setLongitude(longitude); model.setGpsLocation(gpsLocation); } else { model.setGpsLocation(null); } // } Log.i(TAG, "Movie ID : " + movieId); model.setMovie(movie); moviePagedAdapter.changeData(movie, interaction.getMainContext(), model, tracker, this); moviePagedAdapter.notifyDataSetChanged(); if (theaterId != null) { model.setTheater(theater); } moviePagedAdapter.manageViewVisibility(); try { moviePagedAdapter.fillBasicInformations(movie); if (isServiceRunning()) { interaction.openDialog(); } if (movie.getImdbId() == null) { tracker.trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_MOVIE // Category , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action , CineShowtimeCst.ANALYTICS_LABEL_MOVIE_REUSE + 0 // Label , 0 // Value ); searchMovieDetail(movie, near); } else { tracker.trackEvent(CineShowtimeCst.ANALYTICS_CATEGORY_MOVIE // Category , CineShowtimeCst.ANALYTICS_ACTION_INTERACTION // Action , CineShowtimeCst.ANALYTICS_LABEL_MOVIE_REUSE + 1 // Label , 0 // Value ); moviePagedAdapter.fillViews(movie); } } catch (Exception e) { Log.e(TAG, "error on create", e); //$NON-NLS-1$ } }
From source file:com.ximai.savingsmore.save.activity.FourStepRegisterActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { super.onActivityResult(requestCode, resultCode, intent); if (resultCode != RESULT_OK) { return;//w ww .j a v a 2s. c o m } else if (requestCode == PICK_FROM_CAMERA || requestCode == PICK_FROM_IMAGE) { Uri uri = null; if (null != intent && intent.getData() != null) { uri = intent.getData(); } else { String fileName = PreferencesUtils.getString(this, "tempName"); uri = Uri.fromFile(new File(FileSystem.getCachesDir(this, true).getAbsolutePath(), fileName)); } if (uri != null) { cropImage(uri, CROP_PHOTO_CODE); } } else if (requestCode == CROP_PHOTO_CODE) { Uri photoUri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT); if (isslinece) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), slience_image); zhizhao_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "BusinessLicense"); } catch (URISyntaxException e) { e.printStackTrace(); } } else if (isZhengshu) { MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), zhengshu_iamge); xukezheng_path = photoUri.toString(); try { upLoadImage(new File((new URI(photoUri.toString()))), "LicenseKey"); } catch (URISyntaxException e) { e.printStackTrace(); } //upLoadImage(new File((new URI(photoUri.toString()))), "Photo"); } else if (isItem) { if (images.size() < 10) { shangpu_path.add(photoUri.toString()); try { upLoadImage(new File((new URI(photoUri.toString()))), "Seller"); } catch (URISyntaxException e) { e.printStackTrace(); } } else { Toast.makeText(FourStepRegisterActivity.this, "?9", Toast.LENGTH_SHORT).show(); } } //addImage(imagePath); } }