List of usage examples for android.content Intent getExtras
public @Nullable Bundle getExtras()
From source file:com.fsm.storybook.launcher.WebViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(TAG, "onCreate"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_web_view); context = this; bkdb = new BookDatabase(getApplicationContext()); globalApp = (GlobalApplication) this.getApplicationContext(); util = new ActivityUtil(this); currentOrientation = String.valueOf(util.getScreenOrientation()); gestureListener = new ContentGestureListener(this); //gestureListener = new WebViewGestureDetector(); mWebview = (WebView) findViewById(R.id.webview); //mWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mWebview.setOnClickListener(WebViewActivity.this); mWebview.setOnTouchListener(gestureListener); //mHiddenWebview = (WebView) findViewById(R.id.webview_hidden); //mHiddenWebview.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mPageInfo = (TextView) findViewById(R.id.page_info); mPageSlider = (SeekBar) findViewById(R.id.page_slider); mPageSlider.setOnSeekBarChangeListener(this); mPageInfo.setVisibility(View.GONE); mPageSlider.setVisibility(View.GONE); Intent intent = getIntent(); Bundle extras = intent.getExtras(); if (extras == null) return;//from ww w .j a v a2 s . c om //if (intent.getFlags() == Intent.FLAG_ACTIVITY_NEW_TASK) { mContainer = ContainerHolder.getInstance().get(extras.getLong(Constants.CONTAINER_ID)); if (mContainer == null) { finish(); return; } mPackage = mContainer.getDefaultPackage(); //? int bookCode = extras.getInt(Constants.BOOK_CODE); mBookData = bkdb.fetchBook(bookCode); setTitle(mBookData.getTitle()); //??spineitem?spineitem?? List<SpineItem> spineItems = mPackage.getSpineItems(); for (SpineItem item : spineItems) { String idref = item.getIdRef(); mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_PORTRAIT), idref, 1); mBookData.setSpineItemPageCount(String.valueOf(Configuration.ORIENTATION_LANDSCAPE), idref, 1); } bkdb.updateBook(mBookData); /* mBookmarkList = bkdb.fetchBookmarkList(bookCode); mHighlightList = bkdb.fetchHighlightList(bookCode); */ mViewerSettings = new ViewerSettings(mBookData.getSpreadCount() == 2, mBookData.getFontSize(), 20); try { Log.d(TAG, "openPageRequest JSON:" + extras.getString(Constants.OPEN_PAGE_REQUEST_DATA)); mOpenPageRequestData = OpenPageRequest.fromJSON(extras.getString(Constants.OPEN_PAGE_REQUEST_DATA)); } catch (JSONException e) { Log.e(TAG, "Constants.OPEN_PAGE_REQUEST_DATA must be a valid JSON object: " + e.getMessage(), e); } //??? if (mBookData.getTotalPageCount(currentOrientation) <= 0) { pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_NONE; } else { pageCountCaculateStatus = PAGE_COUNT_CAL_STATUS_DONE; } //epub web server new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { mServer = new EpubServer(EpubServer.HTTP_HOST, EpubServer.HTTP_PORT, mPackage, false); mServer.startServer(); return null; } }.execute(); //??hidden webview /* initHiddenWebView(); mHiddenWebview.loadUrl(HIDDEN_READER_SKELETON); mReadiumJSApiForHiddenWebView = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mHiddenWebview.loadUrl(javascript); } }); */ //?webview initWebView(); mWebview.loadUrl(READER_SKELETON); mReadiumJSApi = new ReadiumJSApi(new ReadiumJSApi.JSLoader() { @Override public void loadJS(String javascript) { mWebview.loadUrl(javascript); } }); //} }
From source file:com.parse.ParsePushBroadcastReceiver.java
/** * Called when the push notification is received. By default, a broadcast intent will be sent if * an "action" is present in the data and a notification will be show if "alert" and "title" are * present in the data./* w w w . ja v a 2s . c o m*/ * * @param context * The {@code Context} in which the receiver is running. * @param intent * An {@code Intent} containing the channel and data of the current push notification. */ protected void onPushReceive(Context context, Intent intent) { String pushDataStr = intent.getStringExtra(KEY_PUSH_DATA); if (pushDataStr == null) { PLog.e(TAG, "Can not get push data from intent."); return; } PLog.v(TAG, "Received push data: " + pushDataStr); JSONObject pushData = null; try { pushData = new JSONObject(pushDataStr); } catch (JSONException e) { PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e); } // If the push data includes an action string, that broadcast intent is fired. String action = null; if (pushData != null) { action = pushData.optString("action", null); } if (action != null) { Bundle extras = intent.getExtras(); Intent broadcastIntent = new Intent(); broadcastIntent.putExtras(extras); broadcastIntent.setAction(action); broadcastIntent.setPackage(context.getPackageName()); context.sendBroadcast(broadcastIntent); } Notification notification = getNotification(context, intent); if (notification != null) { ParseNotificationManager.getInstance().showNotification(context, notification); } }
From source file:com.polyvi.xface.extension.camera.XCameraExt.java
private void cameraSucess(Intent intent) { try {/* w w w. ja v a2s.com*/ Bitmap bitmap = null; try { //???imagebitmap if (mAllowEdit) { //??????Android??? //???URI Bundle extras = intent.getExtras(); if (extras != null) { bitmap = extras.getParcelable("data"); } //?????URI if ((bitmap == null) || (extras == null)) { bitmap = getCroppedBitmap(intent); } } else { // ???? bitmap = android.provider.MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), mImageUri); } } catch (FileNotFoundException e) { Uri uri = intent.getData(); android.content.ContentResolver resolver = getContext().getContentResolver(); bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); } catch (IOException e) { mCallbackCtx.error("Can't open image"); } catch (OutOfMemoryError e) { XNotification notification = new XNotification(mExtensionContext.getSystemContext()); notification.alert("Size of Image is too large!", "Save Image Error", "OK", null, DURATION); mCallbackCtx.error("Size of image is too large"); return; } // ??? Bitmap scaleBitmap = scaleBitmap(bitmap); Uri uri = null; if (mDestType == DATA_URL) { processPicture(scaleBitmap); checkForDuplicateImage(DATA_URL); } else if (mDestType == FILE_URI || mDestType == NATIVE_URI) { if (!this.mSaveToPhotoAlbum) { String suffixName = null; if (mEncodingType == JPEG) { suffixName = ".jpg"; } else if (mEncodingType == PNG) { suffixName = ".png"; } else { throw new IllegalArgumentException("Invalid Encoding Type: " + mEncodingType); } String photoName = System.currentTimeMillis() + suffixName; uri = Uri.fromFile(new File(mWebContext.getWorkSpace(), photoName)); } else { uri = getUriFromMediaStore(); } if (uri == null) { mCallbackCtx.error("Error capturing image - no media storage found."); } // ? OutputStream os = getContext().getContentResolver().openOutputStream(uri); scaleBitmap.compress(Bitmap.CompressFormat.JPEG, mQuality, os); os.close(); // ??success callback XPathResolver pathResolver = new XPathResolver(uri.toString(), "", getContext()); mCallbackCtx.success(XConstant.FILE_SCHEME + pathResolver.resolve()); } scaleBitmap.recycle(); scaleBitmap = null; cleanup(FILE_URI, mImageUri, uri, bitmap); } catch (IOException e) { mCallbackCtx.error("Error capturing image."); } }
From source file:com.parse.ParsePushBroadcastReceiver.java
/** * Called when the push notification is opened by the user. Sends analytics info back to Parse * that the application was opened from this push notification. By default, this will navigate * to the {@link Activity} returned by {@link #getActivity(Context, Intent)}. If the push contains * a 'uri' parameter, an Intent is fired to view that URI with the Activity returned by * {@link #getActivity} in the back stack. * * @param context/*from w w w . j a v a 2s . co m*/ * The {@code Context} in which the receiver is running. * @param intent * An {@code Intent} containing the channel and data of the current push notification. */ protected void onPushOpen(Context context, Intent intent) { // Send a Parse Analytics "push opened" event ParseAnalytics.trackAppOpenedInBackground(intent); String uriString = null; try { JSONObject pushData = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA)); uriString = pushData.optString("uri", null); } catch (JSONException e) { PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e); } Class<? extends Activity> cls = getActivity(context, intent); Intent activityIntent; if (uriString != null) { activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriString)); } else { activityIntent = new Intent(context, cls); } activityIntent.putExtras(intent.getExtras()); /* In order to remove dependency on android-support-library-v4 The reason why we differentiate between versions instead of just using context.startActivity for all devices is because in API 11 the recommended conventions for app navigation using the back key changed. */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { TaskStackBuilderHelper.startActivities(context, cls, activityIntent); } else { activityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activityIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); context.startActivity(activityIntent); } }
From source file:cm.aptoide.pt.ManageRepos.java
private void handleIncomingIntent(Intent incomingIntent) { if (incomingIntent.getExtras() != null && incomingIntent.getExtras().getBoolean(Constants.MYAPP_NEW_REPOS_WAITING)) { Log.d("Aptoide-ManageRepos", "incoming Myapp Repos"); handlingMyappRepos = true;/*from w w w.ja va 2s. c o m*/ receiveMyappRepos(); } }
From source file:edu.mit.mobile.android.locast.sync.MediaSync.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (ACTION_SYNC_RESOURCES.equals(intent.getAction())) { final Uri data = intent.getData(); if (data == null) { enqueueUnpublishedMedia();/* w w w .j a v a 2 s . co m*/ } else { enqueueItem(data, intent.getExtras()); } } else { Log.e(TAG, "Media Sync was told to start with an unhandled intent: " + intent); } return START_REDELIVER_INTENT; }
From source file:com.facebook.android.friendsmash.HomeFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REAUTH_ACTIVITY_CODE) { // This ensures a session state change is recorded so that the tokenUpdated() callback is triggered // to attempt a post if the write permissions have been granted Log.i(FriendSmashApplication.TAG, "Reauthorized with publish permissions."); Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data); } else if (resultCode == Activity.RESULT_OK && data != null) { // Finished a game Bundle bundle = data.getExtras(); application.setScore(bundle.getInt("score")); updateYouScoredTextView();//from w w w .j av a2 s. c o m updateButtonVisibility(); completeGameOver(1500); } else if (resultCode == Activity.RESULT_FIRST_USER && data != null) { // Came from the ScoreboardFragment, so start a game with the specific user who has been clicked Intent i = new Intent(getActivity(), GameActivity.class); Bundle bundle = new Bundle(); bundle.putString("user_id", data.getStringExtra("user_id")); i.putExtras(bundle); startActivityForResult(i, 0); } else if (resultCode == Activity.RESULT_CANCELED && data != null) { Bundle bundle = data.getExtras(); ((HomeActivity) getActivity()).showError(bundle.getString("error"), false); } else if (resultCode == Activity.RESULT_CANCELED && ((FriendSmashApplication) getActivity().getApplication()) .getGameFragmentFBRequestError() != null) { ((HomeActivity) getActivity()).handleError( ((FriendSmashApplication) getActivity().getApplication()).getGameFragmentFBRequestError(), false); ((FriendSmashApplication) getActivity().getApplication()).setGameFragmentFBRequestError(null); } }
From source file:es.uja.photofirma.android.CameraActivity.java
/** * Controla los accesos y retornos a las aplicaciones de caputura de fotografas y '@firma', se establece * para cada caso tanto la situacion de exito como la de fracaso. *//*from w ww . j a v a 2 s.com*/ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // Vuelta de @firma, el resultCode indica exito o fracaso, en cada caso se toman unas medidas diferentes if (requestCode == CameraActivity.APP_FIRMA_REQUEST_CODE && resultCode == CameraActivity.RESULT_ERROR) { logger.appendLog(402, "el usuario deniega el uso del certificado"); showErrorHeader(); } //Vuelta de @firma, la firma fue realizada con exito, se almacena la ruta al archivo if (requestCode == CameraActivity.APP_FIRMA_REQUEST_CODE && resultCode == RESULT_OK) { logger.appendLog(200, "@firma realiz la firma adecuadamente"); signedFileLocation = data.getExtras().getString("signedfilelocation"); showSuccessHeader(); } //Si la captura de la fotografa tuvo exito if (requestCode == CameraActivity.REQUEST_IMAGE_CAPTURE & resultCode == RESULT_OK) { logger.appendLog(101, "el usuario captura foto"); //Se obtienen los datos del servicio de localizacin geografica LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); // Aade los geoTags a la foto realizada anteriormente if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) && location != null) { PhotoCapture.addExifData(photoLocation, location); logger.appendLog(102, "el usuario aade exif"); logger.appendLog(103, "gps data: " + location); } logger.appendLog(104, "buscando @firma"); //Se comprueba si est la app @firma Intent intent = getPackageManager().getLaunchIntentForPackage("es.gob.afirma"); if (intent == null) { //Si no se encuentra instalada se notifica al usuario logger.appendLog(400, "@firma no instalada"); showErrorHeader(); errorText.setText(getString(R.string.camera_activity_no_afirma_present)); } else { //Si se encuentra, entonces se abre para dar comienzo al proceso de firma logger.appendLog(201, "abriendo @firma"); Intent i = new Intent(APP_FIRMA_OPEN_ACTION); i.putExtra(CameraActivity.APP_FIRMA_EXTRA_FILE_PATH, photoLocation); startActivityForResult(i, APP_FIRMA_REQUEST_CODE); } } //Si la captura de fotos fue cancelada if (requestCode == CameraActivity.REQUEST_IMAGE_CAPTURE && resultCode == CameraActivity.RESULT_CANCELED) { showInfoHeader(); logger.appendLog(105, "cierra la app de photo sin captura"); } //Si la captura de fotos fue cancelada if (requestCode == CameraActivity.REQUEST_IMAGE_CAPTURE && resultCode == CameraActivity.RESULT_ERROR) { showInfoHeader(); logger.appendLog(403, "Se produjo un error en la app de Cmara"); } }
From source file:com.hanuor.sapphire.utils.intentation.IntentationPrime.java
public String intentToJSON(Context con, Intent intent) throws JsonProcessingException { ObjectMapper mapper = new ObjectMapper(); String getContextName = null; String getClassName = null;/* ww w .j av a2 s .c o m*/ try { getClassName = intent.getComponent().getClassName(); getContextName = con.getPackageName(); } catch (Exception e) { e.printStackTrace(); } HashMap<String, String> makeInsideJsonArray = new HashMap<String, String>(); HashMap<String, String> hashMap = new HashMap<String, String>(); hashMap.put("className", getClassName); hashMap.put("context", getContextName); Bundle bundle = intent.getExtras(); if (bundle != null) { Set<String> keys = bundle.keySet(); Iterator<String> it = keys.iterator(); Log.d("SappsnoopDog", "" + keys.size()); while (it.hasNext()) { String key = it.next(); Log.d("Sapptagdog", "TYPE " + bundle.get(key).toString()); Log.d("NERVE", "" + bundle.get(key).getClass().getAnnotations()); String type = bundle.get(key).getClass().getSimpleName(); Log.d("SappDogTAG", key + " OF TYPE " + type); switch (type) { case "String": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "String[]": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString().replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Integer": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "Double": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "double[]": double[] newDouble = (double[]) bundle.get(key); String fromDouble = Arrays.toString(newDouble); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromDouble.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "int[]": int[] newArray = (int[]) bundle.get(key); String fromArray = Arrays.toString(newArray); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromArray.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Boolean": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "boolean[]": boolean[] newBool = (boolean[]) bundle.get(key); String fromBool = Arrays.toString(newBool); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromBool.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Char": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "char[]": char[] newChar = (char[]) bundle.get(key); String fromChar = Arrays.toString(newChar); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromChar.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "CharSequence": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "charsequence[]": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString().replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Byte": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "byte[]": byte[] newByte = (byte[]) bundle.get(key); String fromByte = Arrays.toString(newByte); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromByte.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Float": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "float[]": float[] newFloat = (float[]) bundle.get(key); String fromFloat = Arrays.toString(newFloat); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromFloat.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Short": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "short[]": short[] newShort = (short[]) bundle.get(key); String fromShort = Arrays.toString(newShort); fromShort = fromShort.replace(" ", ""); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + fromShort.replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "Long": makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString()); Log.d("SappDogTAG", "bool array"); break; case "long[]": long[] newLong = (long[]) bundle.get(key); String fromLong = Arrays.toString(newLong); makeInsideJsonArray.put(key, type + LibraryDatabase.JSONSEPERATOR + bundle.get(key).toString().replace(" ", "")); Log.d("SappDogTAG", "bool array"); break; case "ArrayList": ArrayList<Object> obj = (ArrayList<Object>) bundle.get(key); Object[] objArr = obj.toArray(); if (objArr[0] instanceof Integer) { ArrayList<Integer> newIntegerArray = bundle.getIntegerArrayList(key); makeInsideJsonArray.put(key, type + "Integer" + LibraryDatabase.JSONSEPERATOR + newIntegerArray.toString().replace(" ", "")); } else if (objArr[0] instanceof String) { ArrayList<String> newStringArray = bundle.getStringArrayList(key); makeInsideJsonArray.put(key, type + "String" + LibraryDatabase.JSONSEPERATOR + newStringArray.toString().replace(" ", "")); } break; default: // whatever } hashMap.put(key, bundle.get(key).toString()); } } String passArray = mapper.writeValueAsString(makeInsideJsonArray); hashMap.put("intentExtras", passArray); Log.d("GOGTAD", "" + passArray); String intentString = mapper.writeValueAsString(intent); Log.d("IntentString", "" + mapper.writeValueAsString(hashMap)); StringBuilder a1S = new StringBuilder(mapper.writeValueAsString(hashMap)); a1S.deleteCharAt(mapper.writeValueAsString(hashMap).length() - 1); a1S.append(","); String s1t = a1S.toString(); StringBuilder sb = new StringBuilder(intentString); sb.deleteCharAt(0); String retrString = sb.toString(); StringBuilder newS = new StringBuilder(); newS.append(s1t); newS.append(retrString); Log.d("Insnsns", newS.toString()); return newS.toString(); }
From source file:com.dwdesign.tweetings.fragment.StatusFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent intent) { if (intent == null || mStatus == null) return;/*from w w w .java2 s .c o m*/ switch (requestCode) { case REQUEST_SET_COLOR: { if (resultCode == Activity.RESULT_OK) if (intent != null && intent.getExtras() != null) { final int color = intent.getIntExtra(Accounts.USER_COLOR, Color.TRANSPARENT); setUserColor(getActivity(), mStatus.user_id, color); updateUserColor(); } break; } } }