List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:crea.wallet.lite.service.CreativeCoinService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.e(TAG, "onStartCommand"); org.creativecoinj.core.Context.propagate(CONTEXT); if (intent != null) { Log.i(TAG,//from ww w .j a v a 2 s . c o m "service start command: " + intent + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT) ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")" : "")); final String action = intent.getAction(); if (ACTION_CANCEL_COINS_RECEIVED.equals(action)) { notificationAccumulatedAmount = Coin.ZERO; transactionsReceived.clear(); if (nm != null) { nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } } else if (ACTION_BROADCAST_TRANSACTION.equals(action)) { broadcastTransactionPendingTx(intent); } else if (ACTION_RESET_BLOCKCHAIN.equals(action)) { Log.i(TAG, "will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (ACTION_SEND_PEERS.equals(action)) { broadcastPeers(); } else if (peerGroup != null && peerGroup.isRunning()) { broadcastSyncStarted(); } } else { Log.e(TAG, "service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }
From source file:com.master.metehan.filtereagle.ActivityMain.java
@Override protected void onNewIntent(Intent intent) { Log.i(TAG, "New intent"); Util.logExtras(intent);// w w w . ja v a 2 s . co m super.onNewIntent(intent); if (Build.VERSION.SDK_INT >= MIN_SDK) { if (intent.hasExtra(EXTRA_REFRESH)) updateApplicationList(intent.getStringExtra(EXTRA_SEARCH)); else updateSearch(intent.getStringExtra(EXTRA_SEARCH)); checkExtras(intent); } }
From source file:com.handpoint.headstart.client.ui.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_LOGIN: if (resultCode == RESULT_OK) { if (!data.hasExtra("password")) { return; }/*from w w w . j a va 2s. c o m*/ HeadstartService.setProperty("auth_token", data.getStringExtra("password")); if (null != mImportIntent) { handleIniFile(mImportIntent); mImportIntent = null; } if (null != mVoidIntent) { handleVoidOperation(mVoidIntent); mVoidIntent = null; } } else { if (!isConnected()) { fullUnbindFromService(); } finish(); } break; case REQUEST_CODE_NEW_ACCOUNT: if (resultCode == RESULT_OK) { String pwd = data.getStringExtra("password"); try { mPreferences.edit().putString(SettingsActivity.PREFERENCE_PASSWORD, SecurityUtil.MD5Hash(pwd)) .commit(); } catch (NoSuchAlgorithmException e) { Toast.makeText(this, R.string.error_create_account_failed, Toast.LENGTH_LONG).show(); mImportIntent = null; logger.log(Level.SEVERE, "Error of account creation", e); return; } HeadstartService.setProperty("auth_token", pwd); if (null != mImportIntent) { handleIniFile(mImportIntent); mImportIntent = null; } } else { if (!isConnected()) { fullUnbindFromService(); } finish(); } break; default: super.onActivityResult(requestCode, resultCode, data); } }
From source file:com.Jsu.framework.image.imageChooser.ImageChooserManager.java
@SuppressLint("NewApi") private void processImageFromGallery(Intent data) { if (data != null && data.getDataString() != null) { String uri = data.getData().toString(); sanitizeURI(uri);// ww w . j a v a 2 s . c o m if (filePathOriginal == null || TextUtils.isEmpty(filePathOriginal)) { onError("File path was null"); } else { if (BuildConfig.DEBUG) { Log.i(TAG, "File: " + filePathOriginal); } String path = filePathOriginal; ImageProcessorThread thread = new ImageProcessorThread(path, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); } } else if (data.getClipData() != null || data.hasExtra("uris")) { // Multiple Images String[] filePaths; if (data.hasExtra("uris")) { ArrayList<Uri> uris = data.getParcelableArrayListExtra("uris"); filePaths = new String[uris.size()]; for (int i = 0; i < uris.size(); i++) { filePaths[i] = uris.get(i).toString(); } } else { ClipData clipData = data.getClipData(); int count = clipData.getItemCount(); filePaths = new String[count]; for (int i = 0; i < count; i++) { ClipData.Item item = clipData.getItemAt(i); Log.i(TAG, "processImageFromGallery: Item: " + item.getUri()); filePaths[i] = item.getUri().toString(); } } ImageProcessorThread thread = new ImageProcessorThread(filePaths, foldername, shouldCreateThumbnails); thread.clearOldFiles(clearOldFiles); thread.setListener(this); thread.setContext(getContext()); thread.start(); // } else if () { } else { onError("Image Uri was null!"); } }
From source file:com.actionlauncher.api.LiveWallpaperSource.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;/*ww w .jav a2 s . c om*/ } String action = intent.getAction(); LOGD("LiveWallpaperSource.onHandleIntent() - action:" + action + ", id:" + mName); // TODO: permissions? if (ACTION_SUBSCRIBE.equals(action)) { processSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT), intent.getStringExtra(EXTRA_TOKEN)); } else if (ACTION_FETCH_PALETTE.equals(action)) { publishCurrentPalette(); } else if (action.equals(ProtocolConstants.ACTION_PUBLISH_STATE)) { boolean wallpaperInfoSet = false; if (intent.hasExtra(EXTRA_LIVE_WALLPAPER_INFO)) { Bundle bundle = intent.getExtras().getBundle(EXTRA_LIVE_WALLPAPER_INFO); if (bundle != null) { LiveWallpaperInfo info = LiveWallpaperInfo.fromBundle(bundle); mCurrentState.setCurrentLiveWallpaperInfo(info); LOGD("LiveWallpaperInfo.fromBundle():" + (info != null ? info.toString() : null)); wallpaperInfoSet = true; } } if (!wallpaperInfoSet) { mCurrentState.setCurrentLiveWallpaperInfo(null); } publishCurrentPalette(); } }
From source file:com.zhengde163.netguard.ActivityMain.java
private void checkExtras(Intent intent) { // Approve request if (intent.hasExtra(EXTRA_APPROVE)) { Log.i(TAG, "Requesting VPN approval"); if (enabled) { ivEnabled.setImageResource(R.drawable.on); } else {/*from w w w . jav a 2 s .c o m*/ ivEnabled.setImageResource(R.drawable.off); } } if (intent.hasExtra(EXTRA_LOGCAT)) { Log.i(TAG, "Requesting logcat"); Intent logcat = getIntentLogcat(); if (logcat.resolveActivity(getPackageManager()) != null) startActivityForResult(logcat, REQUEST_LOGCAT); } }
From source file:br.com.brolam.cloudvision.ui.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); /**// w w w.ja v a 2s . c o m * Validar se o login do usurio foi realizado com sucess. * Sendo importante destacar, se o login for cancelado a MainActivity ser encerrada! */ if (loginHelper.checkLogin(requestCode, resultCode)) { //Verificar se exitem algum requiso para salvar uma imagem. //Observao: Se ocorrer a rotao da tela essa verificao ser cancelada, // sendo assim, essa verificar tambm deve ocorrer novamente na // reconstruo da tela, {@link ImagesHelper.restoreStorageReference } if (this.imagesHelper != null) { this.imagesHelper.onActivityResult(requestCode, resultCode, data); } if ((data != null) && (data.hasExtra(NoteVisionActivity.NOTE_VISION_KEY))) { String noteVisionKey = data.getStringExtra(NoteVisionActivity.NOTE_VISION_KEY); setItemSelectedKey(noteVisionKey); } } }
From source file:com.piusvelte.sonet.core.SonetCreatePost.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (intent != null) { String action = intent.getAction(); if ((action != null) && action.equals(Intent.ACTION_SEND)) { if (intent.hasExtra(Intent.EXTRA_STREAM)) getPhoto((Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM)); if (intent.hasExtra(Intent.EXTRA_TEXT)) { final String text = intent.getStringExtra(Intent.EXTRA_TEXT); mMessage.setText(text);//from w w w. j ava2 s .co m mCount.setText(Integer.toString(text.length())); } chooseAccounts(); } else { Uri data = intent.getData(); if ((data != null) && data.toString().contains(Accounts.getContentUri(this).toString())) { // default to the account passed in, but allow selecting additional accounts Cursor account = this.getContentResolver().query(Accounts.getContentUri(this), new String[] { Accounts._ID, Accounts.SERVICE }, Accounts._ID + "=?", new String[] { data.getLastPathSegment() }, null); if (account.moveToFirst()) mAccountsService.put(account.getLong(0), account.getInt(1)); account.close(); } else if (intent.hasExtra(Widgets.INSTANT_UPLOAD)) { // check if a photo path was passed and prompt user to select the account setPhoto(intent.getStringExtra(Widgets.INSTANT_UPLOAD)); chooseAccounts(); } } } }
From source file:com.marianhello.bgloc.LocationService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { log.info("Received start startId: {} intent: {}", startId, intent); if (provider != null) { provider.onDestroy();/*from www . j a va2 s .c o m*/ } if (intent == null) { //service has been probably restarted so we need to load config from db ConfigurationDAO dao = DAOFactory.createConfigurationDAO(this); try { config = dao.retrieveConfiguration(); } catch (JSONException e) { log.error("Config exception: {}", e.getMessage()); config = new Config(); //using default config } } else { if (intent.hasExtra("config")) { config = intent.getParcelableExtra("config"); } else { config = new Config(); //using default config } } log.debug("Will start service with: {}", config.toString()); LocationProviderFactory spf = new LocationProviderFactory(this); provider = spf.getInstance(config.getLocationProvider()); if (config.getStartForeground()) { // Build a Notification required for running service in foreground. NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle(config.getNotificationTitle()); builder.setContentText(config.getNotificationText()); if (config.getSmallNotificationIcon() != null) { builder.setSmallIcon(getDrawableResource(config.getSmallNotificationIcon())); } else { builder.setSmallIcon(android.R.drawable.ic_menu_mylocation); } if (config.getLargeNotificationIcon() != null) { builder.setLargeIcon(BitmapFactory.decodeResource(getApplication().getResources(), getDrawableResource(config.getLargeNotificationIcon()))); } if (config.getNotificationIconColor() != null) { builder.setColor(this.parseNotificationIconColor(config.getNotificationIconColor())); } // Add an onclick handler to the notification Context context = getApplicationContext(); String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_CANCEL_CURRENT); builder.setContentIntent(contentIntent); Notification notification = builder.build(); notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR; startForeground(startId, notification); } provider.startRecording(); //We want this service to continue running until it is explicitly stopped return START_STICKY; }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
private ImageView getImageView(final Context context, Bitmap photo, String uuid) { ImageView imageView = new ImageView(context); imageView.setLayoutParams(new LinearLayout.LayoutParams(thumbnailWidth, thumbnailHeight)); imageView.setPadding(5, 5, 5, 5);//from w w w . j a v a 2 s .c o m imageView.setImageBitmap(photo); imageView.setBackgroundDrawable(getResources().getDrawable(R.drawable.border_black_1px)); imageView.setTag(uuid); imageView.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { String photoId = (String) v.getTag(); FragmentActivity activity = mFragmentDetail.getActivity(); Intent intent = new Intent(activity, PictureActivity.class); if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session intent.putExtra(FormUtilities.PICTURE_PATH_VIEW, addedIdsToImageViews.get(photoId)); } else if (_pictures.containsKey(photoId)) {// pictures from database Map<String, String> imagePaths = _pictures.get(photoId); String imagePath = imagePaths.get("display"); intent.putExtra(FormUtilities.PICTURE_DB_VIEW, imagePath);// Image temporary path } if (intent.hasExtra(FormUtilities.PICTURE_PATH_VIEW) || intent.hasExtra(FormUtilities.PICTURE_DB_VIEW)) { intent.putExtra(FormUtilities.PICTURE_BITMAP_ID, photoId); activity.startActivityForResult(intent, PICTURE_VIEW_RESULT); } else Toast.makeText(getContext(), "Fail, the picture not found.", Toast.LENGTH_LONG).show(); /* JSONArray form = null; try { form = mFragmentDetail.getSelectedForm(); } catch (JSONException jse) { jse.printStackTrace(); Toast.makeText(getContext(), jse.getMessage(), Toast.LENGTH_LONG).show(); } if (form != null) { try { String json = encodeToJson(); FormUtilities.updatePicture(form, json); } catch (JSONException e) { e.printStackTrace(); }catch (Exception e) { e.printStackTrace(); } } try { refresh(getContext()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); }*/ /** * open in markers to edit it */ // MarkersUtilities.launchOnImage(context, image); /* try { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Image image = imagesDbHelper.getImage(imageIdLong); File tempDir = ResourcesManager.getInstance(context).getTempDir(); String ext = ".jpg"; if (image.getName().endsWith(".png")) ext = ".png"; File imageFile = new File(tempDir, ImageUtilities.getTempImageName(ext)); byte[] imageData = imagesDbHelper.getImageData(image.getId()); ImageUtilities.writeImageDataToFile(imageData, imageFile.getAbsolutePath()); intent.setDataAndType(Uri.fromFile(imageFile), "image*//**//*"); //$NON-NLS-1$ context.startActivity(intent); } catch (Exception e) { //GPLog.error(this, null, e); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); }*/ //Toast.makeText(getContext(), "Implement this action", Toast.LENGTH_LONG).show(); } }); return imageView; }