List of usage examples for android.content Intent getBooleanExtra
public boolean getBooleanExtra(String name, boolean defaultValue)
From source file:org.geometerplus.android.fbreader.network.AuthenticationActivity.java
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); Thread.setDefaultUncaughtExceptionHandler( new org.geometerplus.zlibrary.ui.android.library.UncaughtExceptionHandler(this)); setResult(RESULT_CANCELED);/*from w ww . j av a 2s .c o m*/ setContentView(R.layout.authentication); final Intent intent = getIntent(); final String host = intent.getStringExtra(HOST_KEY); final String area = intent.getStringExtra(AREA_KEY); final String username = intent.getStringExtra(USERNAME_KEY); final String error = intent.getStringExtra(ERROR_KEY); final boolean showSignupLink = intent.getBooleanExtra(SHOW_SIGNUP_LINK_KEY, false); myResource = ZLResource.resource("dialog").getResource("AuthenticationDialog"); setTitle(host != null ? host : myResource.getResource("title").getValue()); if (area != null && !"".equals(area)) { findTextView(R.id.authentication_subtitle).setText(area); } else { findTextView(R.id.authentication_subtitle).setVisibility(View.GONE); } final TextView warningView = findTextView(R.id.authentication_unencrypted_warning); if ("https".equalsIgnoreCase(intent.getStringExtra(SCHEME_KEY))) { warningView.setVisibility(View.GONE); } else { warningView.setText(myResource.getResource("unencryptedWarning").getValue()); } findTextView(R.id.authentication_username_label).setText(myResource.getResource("login").getValue()); findTextView(R.id.authentication_password_label).setText(myResource.getResource("password").getValue()); final TextView usernameView = findTextView(R.id.authentication_username); usernameView.setText(username); final TextView errorView = findTextView(R.id.authentication_error); if (error != null && !"".equals(error)) { errorView.setVisibility(View.VISIBLE); errorView.setText(error); } else { errorView.setVisibility(View.GONE); } if (showSignupLink) { findViewById(R.id.authentication_signup_box).setVisibility(View.VISIBLE); final TextView signupView = (TextView) findViewById(R.id.authentication_signup); signupView.setText(myResource.getResource("register").getValue()); signupView.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_SIGNUP); finish(); } }); } else { findViewById(R.id.authentication_signup_box).setVisibility(View.GONE); } final ZLResource buttonResource = ZLResource.resource("dialog").getResource("button"); final Button okButton = findButton(R.id.authentication_ok_button); okButton.setText(buttonResource.getResource("ok").getValue()); okButton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { final Intent data = new Intent(); data.putExtra(USERNAME_KEY, usernameView.getText().toString()); data.putExtra(PASSWORD_KEY, findTextView(R.id.authentication_password).getText().toString()); setResult(RESULT_OK, data); finish(); } }); final Button cancelButton = findButton(R.id.authentication_cancel_button); cancelButton.setText(buttonResource.getResource("cancel").getValue()); cancelButton.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { finish(); } }); }
From source file:com.hang.exoplayer.PlayService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent != null) { boolean playOrPauseAction = intent.getBooleanExtra(ACTION_PLAY_PAUSE, false); boolean loadAction = intent.getBooleanExtra(ACTION_LOAD, false); boolean exitAction = intent.getBooleanExtra(ACTION_EXIT, false); boolean previousAction = intent.getBooleanExtra(ACTION_PREVIOUS, false); boolean nextAction = intent.getBooleanExtra(ACTION_NEXT, false); if (playOrPauseAction) { boolean isPlaying = SimplePlayer.getInstance().isPlaying(); if (isPlaying) { pause();/* w w w .ja v a2 s.c o m*/ } else { play(); } } else if (loadAction) { ArrayList<String> audioList = intent.getStringArrayListExtra(KEY_LIST); int currentPosition = intent.getIntExtra(KEY_POS, 0); if (playAddresses.containsAll(audioList) && mCurrentPosition == currentPosition) { } else { mCurrentPosition = currentPosition; playAddresses.clear(); playAddresses.addAll(audioList); } play(); } else if (exitAction) { Log.d(TAG, "start exitAction"); stopForeground(true); pause(); if (playStatusReceiver != null) { LocalBroadcastManager.getInstance(this).unregisterReceiver(playStatusReceiver); playStatusReceiver = null; Log.d(TAG, "unregisterReceiver exitAction"); } dismissNotification(); stopSelf(); Log.d(TAG, "end exitAction"); } else if (previousAction) { if (mCurrentPosition > 0) { --mCurrentPosition; play(); } else { Toast.makeText(this, "?~", Toast.LENGTH_SHORT).show(); } } else if (nextAction) { if (mCurrentPosition < playAddresses.size() - 1) { ++mCurrentPosition; play(); } else { Toast.makeText(this, "??~", Toast.LENGTH_SHORT).show(); } } } return super.onStartCommand(intent, flags, startId); }
From source file:com.master.metehan.filtereagle.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);// w w w . jav a 2s . c o m SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (IAB.isPurchased(ActivityPro.SKU_NOTIFY, context) && prefs.getBoolean("install", true)) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false) || prefs.getBoolean("show_stats", false)) ServiceSinkhole.start("receiver", context); } else if (Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Util.sendCrashReport(ex, context); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:android.support.v17.leanback.app.GuidedStepSupportFragmentTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); int layoutDirection = intent.getIntExtra(EXTRA_LAYOUT_DIRECTION, -1); if (layoutDirection != -1) { findViewById(android.R.id.content).setLayoutDirection(layoutDirection); }/* ww w. j a v a 2s . c om*/ if (savedInstanceState == null) { String firstTestName = intent.getStringExtra(EXTRA_TEST_NAME); if (firstTestName != null) { GuidedStepTestSupportFragment testFragment = new GuidedStepTestSupportFragment(firstTestName); if (intent.getBooleanExtra(EXTRA_ADD_AS_ROOT, true)) { GuidedStepTestSupportFragment.addAsRoot(this, testFragment, android.R.id.content); } else { GuidedStepTestSupportFragment.add(getSupportFragmentManager(), testFragment, android.R.id.content); } } } }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.SessionFeedbackFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String chosenAccountName = AccountUtils.getChosenAccountName(getActivity()); mPlusClient = new PlusClient.Builder(getActivity(), this, this).clearScopes() .setAccountName(chosenAccountName).build(); final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments()); mSessionUri = intent.getData();//www . ja v a 2 s . co m if (mSessionUri == null) { return; } mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri); mVariableHeightHeader = intent.getBooleanExtra(EXTRA_VARIABLE_HEIGHT_HEADER, false); LoaderManager manager = getLoaderManager(); manager.restartLoader(0, null, this); setHasOptionsMenu(true); }
From source file:de.quist.app.errorreporter.ExceptionReportService.java
private void sendReport(Intent intent) throws UnsupportedEncodingException, NameNotFoundException { Log.v(TAG, "Got request to report error: " + intent.toString()); Uri server = getTargetUrl();/* w w w. ja va 2s . c om*/ boolean isManualReport = intent.getBooleanExtra(EXTRA_MANUAL_REPORT, false); boolean isReportOnFroyo = isReportOnFroyo(); boolean isFroyoOrAbove = isFroyoOrAbove(); if (isFroyoOrAbove && !isManualReport && !isReportOnFroyo) { // We don't send automatic reports on froyo or above Log.d(TAG, "Don't send automatic report on froyo"); return; } Set<String> fieldsToSend = getFieldsToSend(); String stacktrace = intent.getStringExtra(EXTRA_STACK_TRACE); String exception = intent.getStringExtra(EXTRA_EXCEPTION_CLASS); String message = intent.getStringExtra(EXTRA_MESSAGE); long availableMemory = intent.getLongExtra(EXTRA_AVAILABLE_MEMORY, -1l); long totalMemory = intent.getLongExtra(EXTRA_TOTAL_MEMORY, -1l); String dateTime = intent.getStringExtra(EXTRA_EXCEPTION_TIME); String threadName = intent.getStringExtra(EXTRA_THREAD_NAME); String extraMessage = intent.getStringExtra(EXTRA_EXTRA_MESSAGE); List<NameValuePair> params = new ArrayList<NameValuePair>(); addNameValuePair(params, fieldsToSend, "exStackTrace", stacktrace); addNameValuePair(params, fieldsToSend, "exClass", exception); addNameValuePair(params, fieldsToSend, "exDateTime", dateTime); addNameValuePair(params, fieldsToSend, "exMessage", message); addNameValuePair(params, fieldsToSend, "exThreadName", threadName); if (extraMessage != null) addNameValuePair(params, fieldsToSend, "extraMessage", extraMessage); if (availableMemory >= 0) addNameValuePair(params, fieldsToSend, "devAvailableMemory", availableMemory + ""); if (totalMemory >= 0) addNameValuePair(params, fieldsToSend, "devTotalMemory", totalMemory + ""); PackageManager pm = getPackageManager(); try { PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0); addNameValuePair(params, fieldsToSend, "appVersionCode", packageInfo.versionCode + ""); addNameValuePair(params, fieldsToSend, "appVersionName", packageInfo.versionName); addNameValuePair(params, fieldsToSend, "appPackageName", packageInfo.packageName); } catch (NameNotFoundException e) { } addNameValuePair(params, fieldsToSend, "devModel", android.os.Build.MODEL); addNameValuePair(params, fieldsToSend, "devSdk", android.os.Build.VERSION.SDK); addNameValuePair(params, fieldsToSend, "devReleaseVersion", android.os.Build.VERSION.RELEASE); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(server.toString()); post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); Log.d(TAG, "Created post request"); try { httpClient.execute(post); Log.v(TAG, "Reported error: " + intent.toString()); } catch (ClientProtocolException e) { // Ignore this kind of error Log.e(TAG, "Error while sending an error report", e); } catch (SSLException e) { Log.e(TAG, "Error while sending an error report", e); } catch (IOException e) { if (e instanceof SocketException && e.getMessage().contains("Permission denied")) { Log.e(TAG, "You don't have internet permission", e); } else { int maximumRetryCount = getMaximumRetryCount(); int maximumExponent = getMaximumBackoffExponent(); // Retry at a later point in time AlarmManager alarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); int exponent = intent.getIntExtra(EXTRA_CURRENT_RETRY_COUNT, 0); intent.putExtra(EXTRA_CURRENT_RETRY_COUNT, exponent + 1); PendingIntent operation = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); if (exponent >= maximumRetryCount) { // Discard error Log.w(TAG, "Error report reached the maximum retry count and will be discarded.\nStacktrace:\n" + stacktrace); return; } if (exponent > maximumExponent) { exponent = maximumExponent; } long backoff = (1 << exponent) * 1000; // backoff in ms alarmMgr.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + backoff, operation); } } }
From source file:com.rukman.emde.smsgroups.authenticator.GMSAuthenticatorActivity.java
/** * {@inheritDoc}/*www . j av a 2 s . c o m*/ */ @Override public void onCreate(Bundle icicle) { Log.i(TAG, "onCreate(" + icicle + ")"); super.onCreate(icicle); mAccountManager = AccountManager.get(this); Log.i(TAG, "loading data from Intent"); final Intent intent = getIntent(); mUsername = intent.getStringExtra(PARAM_USERNAME); mIsUnknownAccountName = mUsername == null; mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRM_CREDENTIALS, false); Log.i(TAG, "IsUnknownAccount? : " + mIsUnknownAccountName); requestWindowFeature(Window.FEATURE_LEFT_ICON); setContentView(R.layout.login_activity); getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert); mMessage = (TextView) findViewById(R.id.message); mUsernameEdit = (EditText) findViewById(R.id.username_edit); mPasswordEdit = (EditText) findViewById(R.id.password_edit); mEmailEdit = (EditText) findViewById(R.id.email_edit); mPhoneEdit = (EditText) findViewById(R.id.phone_edit); ((CheckBox) findViewById(R.id.new_account_box)).setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { findViewById(R.id.registration_layout).setVisibility(isChecked ? View.VISIBLE : View.GONE); } }); if (!TextUtils.isEmpty(mUsername)) { mUsernameEdit.setText(mUsername); } mMessage.setText(getMessage()); }
From source file:android_network.hetnet.vpn_service.Receiver.java
@Override public void onReceive(final Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent);/*w ww .j a v a 2s . c om*/ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { // Application added if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) { // Show notification if (true) { int uid = intent.getIntExtra(Intent.EXTRA_UID, -1); notifyNewApplication(uid, context); } } } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) { // Application removed Rule.clearCache(context); if (intent.getBooleanExtra(Intent.EXTRA_DATA_REMOVED, false)) { // Remove settings String packageName = intent.getData().getSchemeSpecificPart(); Log.i(TAG, "Deleting settings package=" + packageName); context.getSharedPreferences("wifi", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("other", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("apply", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("screen_wifi", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("screen_other", Context.MODE_PRIVATE).edit().remove(packageName) .apply(); context.getSharedPreferences("roaming", Context.MODE_PRIVATE).edit().remove(packageName).apply(); context.getSharedPreferences("notify", Context.MODE_PRIVATE).edit().remove(packageName).apply(); int uid = intent.getIntExtra(Intent.EXTRA_UID, 0); if (uid > 0) { DatabaseHelper.getInstance(context).clearAccess(uid, false); NotificationManagerCompat.from(context).cancel(uid); // installed notification NotificationManagerCompat.from(context).cancel(uid + 10000); // access notification } } } else { // Upgrade settings upgrade(true, context); // Start service try { if (prefs.getBoolean("enabled", false)) ServiceSinkhole.start("receiver", context); else if (prefs.getBoolean("show_stats", false)) ServiceSinkhole.run("receiver", context); } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } if (Util.isInteractive(context)) ServiceSinkhole.reloadStats("receiver", context); } }
From source file:br.org.funcate.dynamicforms.views.GPictureView.java
@Override public void setOnActivityResult(Intent data) { Boolean hasPhoto = data.getBooleanExtra(LibraryConstants.OBJECT_EXISTS, false); String imgPath;/* ww w.j ava 2 s.c o m*/ if (hasPhoto) {// response of the CameraActivity with one image imgPath = data.getStringExtra(FormUtilities.PHOTO_COMPLETE_PATH); // TODO: save azimuth on database together with the picture. double azimuth = data.getDoubleExtra(LibraryConstants.AZIMUTH, 0); String uuid = java.util.UUID.randomUUID().toString(); newImagesFromCamera.put(uuid, imgPath); updateValueForm(); try { refresh(getContext()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } if (data.hasExtra(FormUtilities.PICTURE_RESPONSE_REMOVE_VIEW)) { Boolean hasPictureRemoved = data.getBooleanExtra(FormUtilities.PICTURE_RESPONSE_REMOVE_VIEW, false); if (!hasPictureRemoved) {// response of the PictureActivity, used to remove image return; } String photoId = data.getStringExtra(FormUtilities.PICTURE_BITMAP_ID); if (addedIdsToImageViews.containsKey(photoId)) {// pictures on session addedIdsToImageViews.remove(photoId); newImagesFromCamera.remove(photoId); } else if (_pictures.containsKey(photoId)) {// pictures from database _pictures.remove(photoId); } updateValueForm(); try { refresh(getContext()); } catch (Exception e) { e.printStackTrace(); Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }
From source file:com.android.settingslib.drawer.SettingsDrawerActivity.java
@Override protected void onResume() { super.onResume(); if (mDrawerLayout != null) { final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); /**/*w w w . j ava 2 s .com*/ * xinsi * * Intent.ACTION_PACKAGE_REMOVED: * Broadcast Action: An existing application package has been removed from the device. * * Intent.ACTION_PACKAGE_REPLACED: * Broadcast Action: A new version of an application package has been installed, * replacing an existing version that was previously installed. */ filter.addAction(Intent.ACTION_PACKAGE_REMOVED); filter.addAction(Intent.ACTION_PACKAGE_CHANGED); filter.addAction(Intent.ACTION_PACKAGE_REPLACED); filter.addDataScheme("package"); registerReceiver(mPackageReceiver, filter); new CategoriesUpdater().execute(); } final Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(EXTRA_SHOW_MENU)) { if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) { // Intent explicitly set to show menu. showMenuIcon(); } } else if (isTopLevelTile(intent)) { showMenuIcon(); } } }