List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.openerp.base.ir.Attachment.java
public OEDataRow handleResult(int requestCode, Intent data) { Uri uri = null;/*from w w w .j av a 2 s . c o m*/ Bitmap bitmap = null; switch (requestCode) { case REQUEST_AUDIO: uri = data.getData(); break; case REQUEST_CAMERA: bitmap = (Bitmap) data.getExtras().get("data"); uri = data.getData(); break; case REQUEST_IMAGE: uri = data.getData(); break; case REQUEST_FILE: uri = data.getData(); break; default: // Single Attachment (share) uri = data.getParcelableExtra(Intent.EXTRA_STREAM); break; } return uriToDataRow(uri, bitmap); }
From source file:com.fvd.nimbus.MainActivity.java
@SuppressLint("NewApi") @Override/*from www .j a va2 s .c o m*/ protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == TAKE_PHOTO) { if (resultCode == -1) { try { if (data != null) { if (data.hasExtra("data")) { Bitmap bm = data.getParcelableExtra("data"); photoFileName = appSettings.saveTempBitmap(bm); bm.recycle(); } } else { if (outputFileUri != null) photoFileName = outputFileUri.getPath(); else photoFileName = getImagePath(); } if (appSettings.isFileExists(photoFileName)) { Intent iPaint = new Intent(); iPaint.putExtra("temp", true); iPaint.putExtra("path", photoFileName); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); } showProgress(false); } catch (Exception e) { appSettings.appendLog("main:onActivityResult: exception - " + e.getMessage()); showProgress(false); } } else showProgress(false); } else if (requestCode == TAKE_PICTURE) { if (resultCode == -1 && data != null) { boolean temp = false; try { Uri resultUri = data.getData(); String drawString = resultUri.getPath(); String galleryString = getGalleryPath(resultUri); if (galleryString != null && galleryString.length() > 0) { drawString = galleryString; } else { try { InputStream input = getApplicationContext().getContentResolver() .openInputStream(resultUri); Bitmap bm = BitmapFactory.decodeStream(input); drawString = appSettings.saveTempBitmap(bm); bm.recycle(); temp = true; } catch (Exception e) { drawString = ""; showProgress(false); } } if (drawString.length() > 0 && drawString.indexOf("/exposed_content/") == -1) { try { Intent iPaint = new Intent(); iPaint.putExtra("temp", temp); iPaint.putExtra("path", drawString); iPaint.setClassName("com.fvd.nimbus", "com.fvd.nimbus.PaintActivity"); startActivity(iPaint); } catch (Exception e) { } } showProgress(false); } catch (Exception e) { appSettings.appendLog("main:onActivityResult " + e.getMessage()); showProgress(false); } } else showProgress(false); } else if (requestCode == 5) { if (resultCode == RESULT_OK) { userMail = data.getStringExtra("userMail"); userPass = data.getStringExtra("userPass"); serverHelper.getInstance().sendOldRequest("user_register", String.format( "{\"action\": \"user_register\",\"email\":\"%s\",\"password\":\"%s\",\"_client_software\": \"ff_addon\"}", userMail, userPass), ""); } } else if (requestCode == 6) { showLogin(); } else if (requestCode == SHOW_SETTINGS) { switch (resultCode) { case RESULT_FIRST_USER + 1: Intent i = new Intent(getApplicationContext(), PrefsActivity.class); startActivity(i); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 2: if (appSettings.sessionId.length() == 0) showLogin(); else { if (true || appSettings.service == "") { appSettings.sessionId = ""; Editor e = prefs.edit(); e.putString("userMail", userMail); e.putString("userPass", ""); e.putString("sessionId", appSettings.sessionId); e.commit(); showLogin(); } else { i = new Intent(getApplicationContext(), loginWithActivity.class); i.putExtra("logout", "true"); i.putExtra("service", appSettings.service); startActivity(i); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } } break; case RESULT_FIRST_USER + 3: try { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationInfo().packageName))); } catch (Exception e) { } case RESULT_FIRST_USER + 4: Uri uri = Uri.parse( "http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide"); Intent it = new Intent(Intent.ACTION_VIEW, uri); startActivity(it); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); break; case RESULT_FIRST_USER + 5: final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT); alertDialogBuilder.setMessage(getScriptContent("license.txt")).setCancelable(false) .setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // no alert dialog shown //alertDialogShown = null; // canceled setResult(RESULT_CANCELED); // and finish //finish(); } }); // create alert dialog final AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.setTitle(getString(R.string.license_title)); // and show //alertDialogShown = alertDialog; try { alertDialog.show(); } catch (final java.lang.Exception e) { // nothing to do } catch (final java.lang.Error e) { // nothing to do } break; default: break; } } }
From source file:com.mumu.pokemongogo.HeadService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { LatLng mapLocation;/* w ww. j ava 2 s. c o m*/ double mapRadius; if (intent != null) { final String action = intent.getAction(); if (action != null) { configHeadIconShowing(HeadIconView.VISIBLE); switch (action) { case ACTION_HANDLE_NAVIGATION: mapLocation = intent.getParcelableExtra(EXTRA_DATA); Log.d(TAG, "Service receive LAT = " + mapLocation.latitude + " and LONG = " + mapLocation.longitude); mMapLocation = mapLocation; mMessageText = mContext.getString(R.string.msg_map_navigating); doMapNavigation(); break; case ACTION_HANDLE_TELEPORT: mapLocation = intent.getParcelableExtra(EXTRA_DATA); Log.d(TAG, "Service receive LAT = " + mapLocation.latitude + " and LONG = " + mapLocation.longitude); mMapLocation = mapLocation; mMessageText = mContext.getString(R.string.msg_map_teleporting); doMapTeleporting(); break; case ACTION_HANDLE_INCUBATING: mapRadius = intent.getDoubleExtra(EXTRA_DATA, 50.0); Log.d(TAG, "Service receive Radius = " + mapRadius); mAutoIncubatingRadius = mapRadius; mMessageText = mContext.getString(R.string.msg_start_incubating); mHeadIconList.get(IDX_INCUBATOR_ICON).getImageView() .setImageResource(R.drawable.ic_egg_enabled); mHeadIconList.get(IDX_SPEED_ICON).getImageView().setImageResource(R.drawable.ic_slow); mAutoIncubating = true; startAutoIncubating(); break; } } } return START_NOT_STICKY; }
From source file:com.crossconnect.activity.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.d(TAG, "onActivityResult() ResultCode" + resultCode + " RequestCode:" + requestCode); //Result code from child fragments activity is bugged so need to strip off last digits int windowsReqCode = requestCode & 0xffff; if (resultCode == Activity.RESULT_OK && (requestCode == CHAPTER_SELECT_CODE || windowsReqCode == WINDOW_SELECT_CODE || requestCode == NOTES_SELECT_CODE)) { updateBibleText((BibleText) data.getParcelableExtra("BibleText")); mTabHost.setCurrentTabByTag(getSharedPreferences("APP SETTINGS", Context.MODE_PRIVATE) .getString(SharedPreferencesHelper.CURRENT_TAB, BIBLE_TAG)); if (windowsReqCode == WINDOW_SELECT_CODE) { windowId = data.getExtras().getInt("WindowId"); Log.i("Main", "Window ID Received" + windowId); }/* w w w . ja v a 2 s . co m*/ } else if (resultCode == Activity.RESULT_OK && requestCode == TRANSLATION_SELECT_CODE) { bibleText.setTranslation((String) data.getExtras().get("Translation")); updateBibleText((BibleText) data.getParcelableExtra("BibleText")); // new SwordVerseTask().execute(bibleTextView.getBibleText()); } else if (requestCode == SETTINGS_CODE) { updateBibleText(bibleText); } else if (requestCode == NOTES_SELECT_CODE && resultCode == Activity.RESULT_CANCELED) { //refresh if back is hit because note may have been deleted updateBibleText(bibleText); } }
From source file:com.goliathonline.android.kegbot.ui.VendorsFragment.java
public void reloadFromArguments(Bundle arguments) { // Teardown from previous arguments if (mCursor != null) { getActivity().stopManagingCursor(mCursor); mCursor = null;// w w w.j av a 2 s . c om } mCheckedPosition = -1; setListAdapter(null); mHandler.cancelOperation(VendorsQuery._TOKEN); // Load new arguments final Intent intent = BaseActivity.fragmentArgumentsToIntent(arguments); final Uri vendorsUri = intent.getData(); final int vendorQueryToken; if (vendorsUri == null) { return; } String[] projection; mAdapter = new VendorsAdapter(getActivity()); projection = VendorsQuery.PROJECTION; vendorQueryToken = VendorsQuery._TOKEN; setListAdapter(mAdapter); // Start background query to load vendors mHandler.startQuery(vendorQueryToken, null, vendorsUri, projection, null, null, KegbotContract.Users.DEFAULT_SORT); // If caller launched us with specific track hint, pass it along when // launching vendor details. Also start a query to load the track info. mTrackUri = intent.getParcelableExtra(DrinkDetailFragment.EXTRA_TRACK); if (mTrackUri != null) { mHandler.startQuery(TracksQuery._TOKEN, mTrackUri, TracksQuery.PROJECTION); } }
From source file:se.leap.bitmaskclient.ProviderAPI.java
@Override protected void onHandleIntent(Intent command) { final ResultReceiver receiver = command.getParcelableExtra(RECEIVER_KEY); String action = command.getAction(); Bundle parameters = command.getBundleExtra(PARAMETERS); if (provider_api_url == null && preferences.contains(Provider.KEY)) { try {/*w w w. jav a 2s . com*/ JSONObject provider_json = new JSONObject(preferences.getString(Provider.KEY, "")); provider_api_url = provider_json.getString(Provider.API_URL) + "/" + provider_json.getString(Provider.API_VERSION); go_ahead = true; } catch (JSONException e) { go_ahead = false; } } if (action.equalsIgnoreCase(SET_UP_PROVIDER)) { Bundle result = setUpProvider(parameters); if (go_ahead) { if (result.getBoolean(RESULT_KEY)) { receiver.send(PROVIDER_OK, result); } else { receiver.send(PROVIDER_NOK, result); } } } else if (action.equalsIgnoreCase(SIGN_UP)) { UserStatus.updateStatus(UserStatus.SessionStatus.SIGNING_UP, resources); Bundle result = tryToRegister(parameters); if (result.getBoolean(RESULT_KEY)) { receiver.send(SUCCESSFUL_SIGNUP, result); } else { receiver.send(FAILED_SIGNUP, result); } } else if (action.equalsIgnoreCase(LOG_IN)) { UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_IN, resources); Bundle result = tryToAuthenticate(parameters); if (result.getBoolean(RESULT_KEY)) { receiver.send(SUCCESSFUL_LOGIN, result); UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_IN, resources); } else { receiver.send(FAILED_LOGIN, result); UserStatus.updateStatus(UserStatus.SessionStatus.NOT_LOGGED_IN, resources); } } else if (action.equalsIgnoreCase(LOG_OUT)) { UserStatus.updateStatus(UserStatus.SessionStatus.LOGGING_OUT, resources); if (logOut()) { receiver.send(SUCCESSFUL_LOGOUT, Bundle.EMPTY); UserStatus.updateStatus(UserStatus.SessionStatus.LOGGED_OUT, resources); } else { receiver.send(LOGOUT_FAILED, Bundle.EMPTY); UserStatus.updateStatus(UserStatus.SessionStatus.DIDNT_LOG_OUT, resources); } } else if (action.equalsIgnoreCase(DOWNLOAD_CERTIFICATE)) { if (updateVpnCertificate()) { receiver.send(CORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY); } else { receiver.send(INCORRECTLY_DOWNLOADED_CERTIFICATE, Bundle.EMPTY); } } else if (action.equalsIgnoreCase(DOWNLOAD_EIP_SERVICE)) { Bundle result = getAndSetEipServiceJson(); if (result.getBoolean(RESULT_KEY)) { receiver.send(CORRECTLY_DOWNLOADED_EIP_SERVICE, result); } else { receiver.send(INCORRECTLY_DOWNLOADED_EIP_SERVICE, result); } } }
From source file:com.openerp.addons.messages.MessageComposeActivty.java
/** * Handle message intent filter for attachments * /*from w w w .j a v a 2s .com*/ * @param intent */ private void handleIntentFilter(Intent intent) { attachments_type.put(ATTACHMENT_TYPE.IMAGE, "image/*"); attachments_type.put(ATTACHMENT_TYPE.TEXT_FILE, "application/*"); String action = intent.getAction(); String type = intent.getType(); // Single attachment if (Intent.ACTION_SEND.equals(action) && type != null) { Uri fileUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); file_uris.add(fileUri); handleReceivedFile(); } // Multiple Attachments if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { ArrayList<Uri> fileUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); file_uris.addAll(fileUris); handleReceivedFile(); } // note.note send as mail if (intent.hasExtra("note_body")) { EditText edtBody = (EditText) findViewById(R.id.edtMessageBody); String body = intent.getExtras().getString("note_body"); edtBody.setText(HTMLHelper.stringToHtml(body)); is_note_body = true; } }
From source file:my.home.lehome.service.SendMsgIntentService.java
private void saveAndNotify(Intent intent, String result) { Context context = getApplicationContext(); int rep_code = -1; String desc;//w w w.jav a2s . c o m try { JSONObject jsonObject = new JSONObject(result); rep_code = jsonObject.getInt("code"); desc = jsonObject.getString("desc"); } catch (JSONException e) { e.printStackTrace(); desc = context.getString(R.string.chat_error_json); } Messenger messenger; if (intent.hasExtra("messenger")) messenger = (Messenger) intent.getExtras().get("messenger"); else messenger = null; Message repMsg = Message.obtain(); repMsg.what = MSG_END_SENDING; ChatItem item = intent.getParcelableExtra("pass_item"); ChatItem newItem = null; if (item != null) { if (rep_code == 200) { item.setState(Constants.CHATITEM_STATE_SUCCESS); DBStaticManager.updateChatItem(context, item); } else { if (rep_code == 415) { item.setState(Constants.CHATITEM_STATE_SUCCESS); } else { item.setState(Constants.CHATITEM_STATE_ERROR); } DBStaticManager.updateChatItem(context, item); newItem = new ChatItem(); newItem.setContent(desc); newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_ERROR); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } else { if (rep_code != 200) { Log.d(TAG, result); newItem = new ChatItem(); newItem.setContent(getString(R.string.loc_send_error) + ":" + desc); // TODO - not only loc report newItem.setType(ChatItemConstants.TYPE_SERVER); newItem.setState(Constants.CHATITEM_STATE_SUCCESS); // always set true newItem.setDate(new Date()); DBStaticManager.addChatItem(context, newItem); } } Log.d(TAG, "dequeue item: " + item); if (item == null) return; Bundle bundle = new Bundle(); bundle.putParcelable("item", item); if (newItem != null) bundle.putParcelable("new_item", newItem); bundle.putInt("rep_code", rep_code); if (messenger != null) { repMsg.setData(bundle); try { messenger.send(repMsg); } catch (RemoteException e) { e.printStackTrace(); } } else { Log.d(TAG, "messager is null, send broadcast instead:" + ACTION_SEND_MSG_END); Intent newIntent = new Intent(ACTION_SEND_MSG_END); newIntent.putExtras(bundle); sendBroadcast(newIntent); } }
From source file:com.nbplus.vbroadlauncher.BroadcastWebViewActivity.java
/** * Handle onNewIntent() to inform the fragment manager that the * state is not saved. If you are handling new intents and may be * making changes to the fragment state, you want to be sure to call * through to the super-class here first. Otherwise, if your state * is saved but the activity is not stopped, you could get an * onNewIntent() call which happens before onResume() and trying to * perform fragment operations at that point will throw IllegalStateException * because the fragment manager thinks the state is still saved. * * @param intent/*from w w w .jav a2s . c o m*/ */ @Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Log.d(TAG, "BroadcastWebViewActivity onNewIntent()"); if (mWebViewClient == null) { Log.e(TAG, "mWebViewClient is null.."); return; } if (mWebViewClient != null) { Log.d(TAG, "Prev url is = " + mWebViewClient.getWebView().getUrl()); } String url = null; if (intent != null && Constants.ACTION_SHOW_NOTIFICATION_CONTENTS.equals(getIntent().getAction())) { url = intent.getStringExtra(Constants.EXTRA_SHOW_NOTIFICATION_CONTENTS); } else { mShortcutData = intent.getParcelableExtra(Constants.EXTRA_NAME_SHORTCUT_DATA); url = mShortcutData.getDomain() + mShortcutData.getPath(); } mWebViewClient.stopPageLoading(); Log.d(TAG, ">> reset url = " + url); if (StringUtils.isEmptyString(url) || !Patterns.WEB_URL.matcher(url).matches()) { Log.e(TAG, "Wrong url ...."); new AlertDialog.Builder(this).setMessage(R.string.alert_wrong_page_url) //.setTitle(R.string.alert_network_title) .setCancelable(true) .setPositiveButton(R.string.alert_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { finishActivity(); } }).show(); } else { mWebViewClient.loadWebUrl(url); } }