List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.company.millenium.iwannask.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //GPS//from ww w . ja v a 2 s. c o m locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationListener = new LocationListener() { public void onLocationChanged(Location location) { if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.removeUpdates(this); } } public void onStatusChanged(String string, int integer, Bundle bundle) { } public void onProviderEnabled(String string) { } public void onProviderDisabled(String string) { } }; if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1000, locationListener); } int delay = 30000; // delay for 30 sec. int period = 3000000; // repeat every 5.3min. Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { if (ActivityCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { // Check Permissions Now final int REQUEST_LOCATION = 2; if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)) { // Display UI and wait for user interaction } else { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, REQUEST_LOCATION); } } else { locationManager.removeUpdates(locationListener); } } }, delay, period); getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); Intent mIntent = getIntent(); URL = Constants.SERVER_URL; if (mIntent.hasExtra("url")) { myWebView = null; startActivity(getIntent()); String url = mIntent.getStringExtra("url"); URL = Constants.SERVER_URL + url; } CookieSyncManager.createInstance(this); CookieSyncManager.getInstance().startSync(); myWebView = (WebView) findViewById(R.id.webview); myWebView.getSettings().setGeolocationDatabasePath(this.getFilesDir().getPath()); myWebView.getSettings().setGeolocationEnabled(true); WebSettings webSettings = myWebView.getSettings(); webSettings.setUseWideViewPort(false); if (!DetectConnection.checkInternetConnection(this)) { webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); showNoConnectionDialog(this); } else { webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); } webSettings.setJavaScriptEnabled(true); myWebView.addJavascriptInterface(new webappinterface(this), "android"); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); myWebView.setOverScrollMode(View.OVER_SCROLL_NEVER); //location test webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); myWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { CookieSyncManager.getInstance().sync(); } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); // Ignore SSL certificate errors } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (Uri.parse(url).getHost().equals(Constants.HOST) || Uri.parse(url).getHost().equals(Constants.WWWHOST)) { // This is my web site, so do not override; let my WebView load // the page return false; } // Otherwise, the link is not for a page on my site, so launch // another Activity that handles URLs Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } }); myWebView.setWebChromeClient(new WebChromeClient() { public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { callback.invoke(origin, true, false); } @Override public void onPermissionRequest(final PermissionRequest request) { Log.d(TAG, "onPermissionRequest"); runOnUiThread(new Runnable() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void run() { if (request.getOrigin().toString().equals("https://apprtc-m.appspot.com/")) { request.grant(request.getResources()); } else { request.deny(); } } }); } public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { // Double check that we don't have any existing callbacks if (mFilePathCallback != null) { mFilePathCallback.onReceiveValue(null); } mFilePathCallback = filePathCallback; // Set up the take picture intent Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null; try { photoFile = createImageFile(); takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath); } catch (IOException ex) { // Error occurred while creating the File Log.e(TAG, "Unable to create Image File", ex); } // Continue only if the File was successfully created if (photoFile != null) { mCameraPhotoPath = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } // Set up the intent to get an existing image Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); // Set up the intents for the Intent chooser Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE); return true; } }); // setContentView(myWebView); // myWebView.loadUrl(URL); myWebView.loadUrl(URL); mRegistrationBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // mRegistrationProgressBar.setVisibility(ProgressBar.GONE); SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean sentToken = sharedPreferences.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false); } }; //CookieManager mCookieManager = CookieManager.getInstance(); //Boolean hasCookies = mCookieManager.hasCookies(); //while(!hasCookies); if (checkPlayServices()) { // Start IntentService to register this application with GCM. Intent intent = new Intent(this, RegistrationIntentService.class); //intent.putExtra("session", session); startService(intent); } Boolean isFirstRun = getSharedPreferences("PREFERENCE", MODE_PRIVATE).getBoolean("isFirstRun", true); if (isFirstRun) { //show start activity startActivity(new Intent(MainActivity.this, MyIntro.class)); } //if (!isOnline()) // showNoConnectionDialog(this); getSharedPreferences("PREFERENCE", MODE_PRIVATE).edit().putBoolean("isFirstRun", false).commit(); //Pull-to-refresh mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.container); mSwipeRefreshLayout.setOnRefreshListener(this); }
From source file:com.tribesman.wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent != null) { log.info("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)) { notificationCount = 0;//from w ww . java 2s .com notificationAccumulatedAmount = BigInteger.ZERO; notificationAddresses.clear(); nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } else if (ACTION_RESET_BLOCKCHAIN.equals(action)) { log.info("will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (ACTION_BROADCAST_TRANSACTION.equals(action)) { final Sha256Hash hash = new Sha256Hash(intent.getByteArrayExtra(ACTION_BROADCAST_TRANSACTION_HASH)); final Transaction tx = application.getWallet().getTransaction(hash); if (peerGroup != null) { log.info("broadcasting transaction " + tx.getHashAsString()); peerGroup.broadcastTransaction(tx); } else { log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString()); } } } else { log.warn("service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }
From source file:com.fvd.nimbus.MainActivity.java
@SuppressLint("NewApi") @Override//from ww w . ja v a2s . 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.bushstar.htmlcoin_android_wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent != null) { log.info("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 (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) { notificationCount = 0;/*w ww.j a v a 2s.c o m*/ notificationAccumulatedAmount = BigInteger.ZERO; notificationAddresses.clear(); nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } else if (BlockchainService.ACTION_RESET_BLOCKCHAIN.equals(action)) { log.info("will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (BlockchainService.ACTION_BROADCAST_TRANSACTION.equals(action)) { final Sha256Hash hash = new Sha256Hash( intent.getByteArrayExtra(BlockchainService.ACTION_BROADCAST_TRANSACTION_HASH)); final Transaction tx = application.getWallet().getTransaction(hash); if (peerGroup != null) { log.info("broadcasting transaction " + tx.getHashAsString()); peerGroup.broadcastTransaction(tx); } else { log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString()); } } } else { log.warn("service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }
From source file:de.azapps.mirakel.new_ui.activities.MirakelActivity.java
private void handleIntent(final Intent intent) { if (intent == null) { return;//from w w w .j a va 2s . co m } switch (intent.getAction()) { case DefinitionsHelper.SHOW_TASK: case DefinitionsHelper.SHOW_TASK_FROM_WIDGET: case DefinitionsHelper.SHOW_TASK_REMINDER: final Optional<Task> task = TaskHelper.getTaskFromIntent(intent); if (task.isPresent()) { setList(task.get().getList()); onTaskSelected(task.get()); } break; case Intent.ACTION_SEND: case Intent.ACTION_SEND_MULTIPLE: // TODO break; case DefinitionsHelper.SHOW_LIST: case DefinitionsHelper.SHOW_LIST_FROM_WIDGET: if (intent.hasExtra(DefinitionsHelper.EXTRA_LIST)) { setList((ListMirakel) intent.getParcelableExtra(DefinitionsHelper.EXTRA_LIST)); } else { Log.d(TAG, "show_list does not pass list, so ignore this"); } break; case Intent.ACTION_SEARCH: // TODO break; case DefinitionsHelper.ADD_TASK_FROM_WIDGET: // TODO break; case DefinitionsHelper.SHOW_MESSAGE: // TODO break; } }
From source file:com.woofy.haifa.MapActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR); pic_map = new HashMap<String, Bitmap>(); // background = false; if (servicesOK()) { setContentView(R.layout.activity_map); Intent service = new Intent(this, MessageService.class); startService(service);/*from w w w .java2s. co m*/ if (initMap()) { //mMap.setMyLocationEnabled(true); mLocationClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API) .addConnectionCallbacks(this).addOnConnectionFailedListener(this).build(); mLocationClient.connect(); new Thread(new Runnable() { boolean mStopHandler = false; @Override public void run() { // while (true) { if (!background) { showPeople(); } if (!mStopHandler) { mHandler.postDelayed(this, 3000); } // } } }).start(); userLocation(true);//goto user`s location Intent i = getIntent(); if (i.hasExtra("gamestartresult")) { joinGame(i.getStringExtra("gamestartresult"), i.getIntExtra("game_id", 0)); } } else { Toast.makeText(this, "Map not available!", Toast.LENGTH_SHORT).show(); } } else { setContentView(R.layout.activity_main); } }
From source file:com.owncloud.android.services.OperationsService.java
/** * Creates a new operation, as described by operationIntent. * // w w w. ja va 2 s.co m * TODO - move to ServiceHandler (probably) * * @param operationIntent Intent describing a new operation to queue and execute. * @return Pair with the new operation object and the information about its * target server. */ private Pair<Target, RemoteOperation> newOperation(Intent operationIntent) { RemoteOperation operation = null; Target target = null; try { if (!operationIntent.hasExtra(EXTRA_ACCOUNT) && !operationIntent.hasExtra(EXTRA_SERVER_URL)) { Log_OC.e(TAG, "Not enough information provided in intent"); } else { Account account = operationIntent.getParcelableExtra(EXTRA_ACCOUNT); String serverUrl = operationIntent.getStringExtra(EXTRA_SERVER_URL); String cookie = operationIntent.getStringExtra(EXTRA_COOKIE); target = new Target(account, (serverUrl == null) ? null : Uri.parse(serverUrl), cookie); String action = operationIntent.getAction(); if (action.equals(ACTION_CREATE_SHARE_VIA_LINK)) { // Create public share via link String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); if (remotePath != null && remotePath.length() > 0) { operation = new CreateShareViaLinkOperation(remotePath); String name = operationIntent.getStringExtra(EXTRA_SHARE_NAME); ((CreateShareViaLinkOperation) operation).setName(name); String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD); ((CreateShareViaLinkOperation) operation).setPassword(password); long expirationDateMillis = operationIntent .getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0); ((CreateShareViaLinkOperation) operation).setExpirationDateInMillis(expirationDateMillis); Boolean uploadToFolderPermission = operationIntent .getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false); ((CreateShareViaLinkOperation) operation).setPublicUpload(uploadToFolderPermission); int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, OCShare.DEFAULT_PERMISSION); ((CreateShareViaLinkOperation) operation).setPermissions(permissions); } } else if (ACTION_UPDATE_SHARE_VIA_LINK.equals(action)) { long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1); operation = new UpdateShareViaLinkOperation(shareId); String name = operationIntent.getStringExtra(EXTRA_SHARE_NAME); ((UpdateShareViaLinkOperation) operation).setName(name); String password = operationIntent.getStringExtra(EXTRA_SHARE_PASSWORD); ((UpdateShareViaLinkOperation) operation).setPassword(password); long expirationDate = operationIntent.getLongExtra(EXTRA_SHARE_EXPIRATION_DATE_IN_MILLIS, 0); ((UpdateShareViaLinkOperation) operation).setExpirationDate(expirationDate); if (operationIntent.hasExtra(EXTRA_SHARE_PUBLIC_UPLOAD)) { ((UpdateShareViaLinkOperation) operation) .setPublicUpload(operationIntent.getBooleanExtra(EXTRA_SHARE_PUBLIC_UPLOAD, false)); } if (operationIntent.hasExtra(EXTRA_SHARE_PERMISSIONS)) { ((UpdateShareViaLinkOperation) operation).setPermissions( operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, OCShare.DEFAULT_PERMISSION)); } } else if (ACTION_UPDATE_SHARE_WITH_SHAREE.equals(action)) { // Update private share, only permissions long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1); operation = new UpdateSharePermissionsOperation(shareId); int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, 1); ((UpdateSharePermissionsOperation) operation).setPermissions(permissions); } else if (action.equals(ACTION_CREATE_SHARE_WITH_SHAREE)) { // Create private share with user or group String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String shareeName = operationIntent.getStringExtra(EXTRA_SHARE_WITH); ShareType shareType = (ShareType) operationIntent.getSerializableExtra(EXTRA_SHARE_TYPE); int permissions = operationIntent.getIntExtra(EXTRA_SHARE_PERMISSIONS, -1); if (remotePath.length() > 0) { operation = new CreateShareWithShareeOperation(remotePath, shareeName, shareType, permissions); } } else if (action.equals(ACTION_UNSHARE)) { // Unshare file long shareId = operationIntent.getLongExtra(EXTRA_SHARE_ID, -1); operation = new RemoveShareOperation(shareId); } else if (action.equals(ACTION_GET_SERVER_INFO)) { // check OC server and get basic information from it operation = new GetServerInfoOperation(serverUrl, OperationsService.this); } else if (action.equals(ACTION_OAUTH2_GET_ACCESS_TOKEN)) { // CREATE ACCESS TOKEN to the OAuth server String code = operationIntent.getStringExtra(EXTRA_OAUTH2_AUTHORIZATION_CODE); OAuth2Provider oAuth2Provider = OAuth2ProvidersRegistry.getInstance().getProvider(); OAuth2RequestBuilder builder = oAuth2Provider.getOperationBuilder(); builder.setGrantType(OAuth2GrantType.AUTHORIZATION_CODE); builder.setRequest(OAuth2RequestBuilder.OAuthRequest.CREATE_ACCESS_TOKEN); builder.setAuthorizationCode(code); operation = builder.buildOperation(); } else if (action.equals(ACTION_GET_USER_NAME)) { // Get User Name operation = new GetRemoteUserInfoOperation(); } else if (action.equals(ACTION_RENAME)) { // Rename file or folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String newName = operationIntent.getStringExtra(EXTRA_NEWNAME); operation = new RenameFileOperation(remotePath, newName); } else if (action.equals(ACTION_REMOVE)) { // Remove file or folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); boolean onlyLocalCopy = operationIntent.getBooleanExtra(EXTRA_REMOVE_ONLY_LOCAL, false); operation = new RemoveFileOperation(remotePath, onlyLocalCopy); } else if (action.equals(ACTION_CREATE_FOLDER)) { // Create Folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); boolean createFullPath = operationIntent.getBooleanExtra(EXTRA_CREATE_FULL_PATH, true); operation = new CreateFolderOperation(remotePath, createFullPath); } else if (action.equals(ACTION_SYNC_FILE)) { // Sync file String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); operation = new SynchronizeFileOperation(remotePath, account, getApplicationContext()); } else if (action.equals(ACTION_SYNC_FOLDER)) { // Sync folder (all its descendant files are sync'ed) String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); boolean pushOnly = operationIntent.getBooleanExtra(EXTRA_PUSH_ONLY, false); boolean syncContentOfRegularFiles = operationIntent.getBooleanExtra(EXTRA_SYNC_REGULAR_FILES, false); operation = new SynchronizeFolderOperation(this, // TODO remove this dependency from construction time remotePath, account, System.currentTimeMillis(), // TODO remove this dependency from construction time pushOnly, false, syncContentOfRegularFiles); } else if (action.equals(ACTION_MOVE_FILE)) { // Move file/folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH); operation = new MoveFileOperation(remotePath, newParentPath); } else if (action.equals(ACTION_COPY_FILE)) { // Copy file/folder String remotePath = operationIntent.getStringExtra(EXTRA_REMOTE_PATH); String newParentPath = operationIntent.getStringExtra(EXTRA_NEW_PARENT_PATH); operation = new CopyFileOperation(remotePath, newParentPath, account); } else if (action.equals(ACTION_CHECK_CURRENT_CREDENTIALS)) { // Check validity of currently stored credentials for a given account operation = new CheckCurrentCredentialsOperation(account); } } } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Bad information provided in intent: " + e.getMessage()); operation = null; } if (operation != null) { return new Pair<>(target, operation); } else { return null; } }
From source file:com.hamradiocoin.wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent != null) { log.info("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)) { notificationCount = 0;//from w w w. ja v a 2s . com notificationAccumulatedAmount = BigInteger.ZERO; notificationAddresses.clear(); nm.cancel(NOTIFICATION_ID_COINS_RECEIVED); } else if (ACTION_RESET_BLOCKCHAIN.equals(action)) { log.info("will remove blockchain on service shutdown"); resetBlockchainOnShutdown = true; stopSelf(); } else if (ACTION_BROADCAST_TRANSACTION.equals(action)) { final Sha256Hash hash = new Sha256Hash(intent.getByteArrayExtra(ACTION_BROADCAST_TRANSACTION_HASH)); final Transaction tx = application.getWallet().getTransaction(hash); if (peerGroup != null) { log.info("broadcasting transaction " + tx.getHashAsString()); peerGroup.broadcastTransaction(tx); } else { log.info("peergroup not available, not broadcasting transaction " + tx.getHashAsString()); } } } else { log.warn("service restart, although it was started as non-sticky"); } return START_NOT_STICKY; }
From source file:com.inmovilizaciones.activity.ListarInmovilizacionesActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); try {//ww w . ja v a 2 s. co m UtilidadesGenerales.context = this; setContentView(R.layout.listar_inmovilizacion_activity); this.app = (AplicacionInmovilizaciones) getApplication(); this.daoSession = this.app.getDaoSession(); this.inmovilizacionDao = this.daoSession.getInmovilizacionDao(); this.departamentosDao = this.daoSession.getDepartamentoDao(); this.municipioDao = this.daoSession.getMunicipioDao(); this.infraccionDao = this.daoSession.getInfraccionDao(); this.parqueaderoDao = this.daoSession.getParqueaderoDao(); this.zonasDao = this.daoSession.getZonasDao(); this.tipoIdentificacionDao = this.daoSession.getTipoIdentificacionDao(); this.gruasDao = this.daoSession.getGruaDao(); this.coloresDao = this.daoSession.getColorDao(); this.tipoServicioDao = this.daoSession.getTipoServicioDao(); this.claseVehiculoDao = this.daoSession.getClaseVehiculoDao(); this.personasDao = this.daoSession.getPersonaDao(); this.vehiculoDao = this.daoSession.getVehiculoDao(); this.rv = (RecyclerView) findViewById(R.id.rv); this.rv.setHasFixedSize(true); this.llm = new LinearLayoutManager(this); this.rv.setLayoutManager(this.llm); Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction()) && !intent.hasExtra("MainSearchResults") && !intent.hasExtra("query")) { onSearchRequested(); } btnAgregarComparendo = (FloatingActionButton) findViewById(R.id.agregarComparendo); btnAgregarComparendo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { if (ListarInmovilizacionesActivity.this.validarParametrizacion().equals("")) { ListarInmovilizacionesActivity.this .startActivityForResult(new Intent(ListarInmovilizacionesActivity.this, AgregarInmovilizacionActivity.class), NOTIFICACIONES_ID); } } }); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.piusvelte.sonet.core.StatusDialog.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(Widgets.INSTANT_UPLOAD)) { mFilePath = intent.getStringExtra(Widgets.INSTANT_UPLOAD); Log.d(TAG, "upload photo?" + mFilePath); } else {//w w w .jav a 2 s. co m mData = intent.getData(); if (mData != null) { mData = intent.getData(); if (intent.hasExtra(LauncherIntent.Extra.Scroll.EXTRA_SOURCE_BOUNDS)) mRect = intent.getParcelableExtra(LauncherIntent.Extra.Scroll.EXTRA_SOURCE_BOUNDS); else mRect = intent.getSourceBounds(); Log.d(TAG, "data:" + mData.toString()); // need to use a thread here to avoid anr mLoadingDialog = new ProgressDialog(this); mLoadingDialog.setMessage(getString(R.string.status_loading)); mLoadingDialog.setCancelable(true); mLoadingDialog.setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface arg0) { if (mStatusLoader != null) mStatusLoader.cancel(true); finish(); } }); mLoadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); finish(); } }); mLoadingDialog.show(); mStatusLoader = new StatusLoader(); mStatusLoader.execute(); } } } if (mFilePath != null) { mDialog = (new AlertDialog.Builder(this)).setTitle(R.string.uploadprompt) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult( Sonet.getPackageIntent(getApplicationContext(), SonetCreatePost.class) .putExtra(Widgets.INSTANT_UPLOAD, mFilePath), RESULT_REFRESH); dialog.dismiss(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); StatusDialog.this.finish(); } }).create(); mDialog.show(); } else { // check if the dialog is still loading if (mFinish) finish(); else if ((mLoadingDialog == null) || !mLoadingDialog.isShowing()) showDialog(); } }