Example usage for android.content Intent getBooleanExtra

List of usage examples for android.content Intent getBooleanExtra

Introduction

In this page you can find the example usage for android.content Intent getBooleanExtra.

Prototype

public boolean getBooleanExtra(String name, boolean defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.cyanogenmod.settings.otgtoggle.UsbDeviceMonitorService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    final String action = intent != null ? intent.getAction() : null;

    if (ACTION_SET_DETECTION_MODE.equals(action)) {
        int mode = intent.getIntExtra(EXTRA_MODE, -1);
        boolean permanent = intent.getBooleanExtra(EXTRA_PERMANENT, false);
        if (mode >= MODE_AUTO && mode <= MODE_OTG) {
            if (permanent) {
                mPrefs.edit().putInt(PREF_DETECTION_MODE, mode).apply();
            }//  w w  w . j  ava 2  s. c  o  m
            mStateMachine.sendMessage(UsbPortStateMachine.DETECTION_MODE_CHANGED, mode);
        }
    }

    return START_STICKY;
}

From source file:bala.padio.Player.java

@Override
public int onStartCommand(final Intent intent, int flags, int startId) {
    Runnable runnable = new Runnable() {
        @Override/*ww w.  j av a 2  s  . c  om*/
        public void run() {
            try {
                boolean isStop = intent.getBooleanExtra(CmdStop, false);

                if (isStop) {
                    Stop();
                } else {
                    Play(Settings.getSelectedChannelUrl());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };
    new Thread(runnable).start();

    return Service.START_NOT_STICKY;
}

From source file:com.manning.androidhacks.hack023.authenticator.AuthenticatorActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mAccountManager = AccountManager.get(this);
    checkMaximumNumberOfAccounts();//from  w w w  .jav a 2 s.c  o m

    final Intent intent = getIntent();

    mUser = intent.getStringExtra(PARAM_USER);
    mAuthTokenType = intent.getStringExtra(PARAM_AUTHTOKEN_TYPE);
    mRequestNewAccount = mUsername == null;
    mConfirmCredentials = intent.getBooleanExtra(PARAM_CONFIRMCREDENTIALS, false);

    Log.i(TAG, "    request new: " + mRequestNewAccount);
    requestWindowFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.login);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, android.R.drawable.ic_dialog_alert);

    findViews();
    initFields();
}

From source file:com.pindroid.activity.AddBookmark.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.add_bookmark);

    Intent intent = getIntent();

    if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) {

        // we don't need to ask for an account if the intent was generated internally
        if (!intent.hasExtra(Constants.EXTRA_INTERNAL)
                || !intent.getBooleanExtra(Constants.EXTRA_INTERNAL, true))
            requestAccount();/*  ww  w .  jav a  2 s. c om*/

        bookmark = new Bookmark();

        loadBookmarkFromShareIntent();

        if (bookmark.getUrl().equals("")) {
            Toast.makeText(this, R.string.add_bookmark_invalid_url, Toast.LENGTH_LONG).show();
        }

        findExistingBookmark();

    } else if (Intent.ACTION_EDIT.equals(intent.getAction())) {
        int id = Integer.parseInt(intent.getData().getLastPathSegment());
        try {
            bookmark = BookmarkManager.GetById(id, this);
            oldBookmark = bookmark.copy();

            update = true;
        } catch (ContentNotFoundException e) {
            e.printStackTrace();
        }
    }

    if (update)
        setTitle(getString(R.string.add_bookmark_edit_title));
    else
        setTitle(getString(R.string.add_bookmark_add_title));

    frag = (AddBookmarkFragment) getSupportFragmentManager().findFragmentById(R.id.add_bookmark_fragment);
    frag.loadBookmark(bookmark, oldBookmark);
    frag.setUsername(app.getUsername());
}

From source file:com.sender.team.sender.gcm.MyGcmListenerService.java

private void confirmNotification(final String message) {
    OtherUserRequest request = new OtherUserRequest(this, PropertyManager.getInstance().getReceiver_id());
    NetworkManager.getInstance().getNetworkData(NetworkManager.CLIENT_STANDARD, request,
            new NetworkManager.OnResultListener<NetworkResult<UserData>>() {
                @Override//www.j  a  va 2s.c o  m
                public void onSuccess(NetworkRequest<NetworkResult<UserData>> request,
                        NetworkResult<UserData> result) {
                    UserData data;
                    data = result.getResult();
                    data.setContractId(PropertyManager.getInstance().getLastContractId());
                    DBManager.getInstance().addMessage(data, ChattingListData.TYPE_SENDER, null,
                            ChatContract.ChatMessage.TYPE_SEND, null, new Date());

                    Intent i = new Intent(ACTION_CONFIRM);
                    mLBM.sendBroadcastSync(i);
                    boolean processed = i.getBooleanExtra(EXTRA_RESULT_CONFIRM, false);
                    if (!processed) {
                        sendNotificationConfirm();
                    }
                }

                @Override
                public void onFail(NetworkRequest<NetworkResult<UserData>> request,
                        NetworkResult<UserData> result, String errorMessage, Throwable e) {

                }
            });
}

From source file:com.google.samples.apps.gcmplayground.MyActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my);

    registerButton = (Button) findViewById(R.id.register_button);
    unregisterButton = (Button) findViewById(R.id.unregister_button);
    stringIdentifierField = (EditText) findViewById(R.id.string_identifier);
    registrationTokenFieldView = (TextView) findViewById(R.id.registeration_token);
    statusView = (TextView) findViewById(R.id.status);
    downstreamBundleView = (TextView) findViewById(R.id.downstream_bundle);
    upstreamMessageField = (EditText) findViewById(R.id.upstream_message);
    sendButton = (Button) findViewById(R.id.button_send);
    subscribeTopicButton = (Button) findViewById(R.id.topic_subscribe);
    topicField = (EditText) findViewById(R.id.topic_name);
    progressBar = (ProgressBar) findViewById(R.id.progress_bar);

    gcm = GoogleCloudMessaging.getInstance(this);
    pubSub = GcmPubSub.getInstance(this);

    // If Play Services is not up to date, quit the app.
    checkPlayServices();//from  ww  w .j ava 2s .c o m

    registerButton.setOnClickListener(this);
    unregisterButton.setOnClickListener(this);
    subscribeTopicButton.setOnClickListener(this);
    sendButton.setOnClickListener(this);

    // Restore from saved instance state
    if (savedInstanceState != null) {
        token = savedInstanceState.getString(RegistrationConstants.EXTRA_KEY_TOKEN, "");
        if (token != "") {
            updateUI("Registration SUCCEEDED", true);
        }
    }

    mRegistrationBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            boolean sentToken = intent.getBooleanExtra(RegistrationConstants.SENT_TOKEN_TO_SERVER, false);

            token = intent.getStringExtra(RegistrationConstants.EXTRA_KEY_TOKEN);
            if (!sentToken) {
                updateUI("Registration FAILED", false);
            }
        }
    };

    mDownstreamBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String from = intent.getStringExtra(RegistrationConstants.SENDER_ID);
            Bundle data = intent.getBundleExtra(RegistrationConstants.EXTRA_KEY_BUNDLE);
            String message = data.getString(RegistrationConstants.EXTRA_KEY_MESSAGE);

            Log.d(TAG, "Received from >" + from + "< with >" + data.toString() + "<");
            Log.d(TAG, "Message: " + message);

            String action = data.getString(RegistrationConstants.ACTION);
            String status = data.getString(RegistrationConstants.STATUS);

            if (RegistrationConstants.REGISTER_NEW_CLIENT.equals(action)
                    && RegistrationConstants.STATUS_REGISTERED.equals(status)) {
                progressBar.setVisibility(View.INVISIBLE);
                updateUI("Registration SUCCEEDED", true);
            } else if (RegistrationConstants.UNREGISTER_CLIENT.equals(action)
                    && RegistrationConstants.STATUS_UNREGISTERED.equals(status)) {
                token = "";
                updateUI("Unregistration SUCCEEDED", false);
                showToast("Unregistered!");
            } else {
                downstreamBundleView.setText(data.toString());
            }
        }
    };

    LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
            new IntentFilter(RegistrationConstants.REGISTRATION_COMPLETE));
    LocalBroadcastManager.getInstance(this).registerReceiver(mDownstreamBroadcastReceiver,
            new IntentFilter(RegistrationConstants.NEW_DOWNSTREAM_MESSAGE));

    stringIdentifierField.setText("<a_name_to_recognize_the_device>");
}

From source file:com.otaupdater.SettingsActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (intent.getBooleanExtra(EXTRA_SHOW_GET_PROKEY_DLG, false)) {
        showGetProKeyDialog();/*w  ww  .ja  va2  s  . c  om*/
    }
}

From source file:com.cloudkick.DashboardActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == SETTINGS_ACTIVITY_ID) {
        reloadAPI();/*from  w ww.j  a va2 s .c o m*/
    }
    if (requestCode == LOGIN_ACTIVITY_ID) {
        // TODO: There is definitely a better way to do this
        try {
            if (data.getBooleanExtra("login", false)) {
                reloadAPI();
            } else {
                finish();
            }
        } catch (NullPointerException e) {
            finish();
        }
    }
}

From source file:net.oschina.app.ui.MainActivity.java

/**
 * ?//from  w w  w.  j  ava  2s .c  o m
 * 
 * @param fromWhich
 */
private void notifitcationBarClick(Intent fromWhich) {
    if (fromWhich != null) {
        boolean fromNoticeBar = fromWhich.getBooleanExtra("NOTICE", false);
        if (fromNoticeBar) {
            Intent toMyInfor = new Intent(this, SimpleBackActivity.class);
            toMyInfor.putExtra(SimpleBackActivity.BUNDLE_KEY_PAGE, SimpleBackPage.MY_MES.getValue());
            startActivity(toMyInfor);
        }
    }
}

From source file:com.jefftharris.passwdsafe.FileListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    PasswdSafeApp.setupTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_file_list);

    itsNavDrawerFrag = (FileListNavDrawerFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_drawer);
    itsNavDrawerFrag.setUp((DrawerLayout) findViewById(R.id.drawer_layout));
    itsFiles = findViewById(R.id.files);
    itsSync = findViewById(R.id.sync);//  w  w  w .ja  v a2 s .c  o  m
    itsNoPermGroup = findViewById(R.id.no_permission_group);

    Intent intent = getIntent();
    itsIsCloseOnOpen = intent.getBooleanExtra(INTENT_EXTRA_CLOSE_ON_OPEN, false);

    SharedPreferences prefs = Preferences.getSharedPrefs(this);
    prefs.registerOnSharedPreferenceChangeListener(this);
    onSharedPreferenceChanged(prefs, Preferences.PREF_FILE_LEGACY_FILE_CHOOSER);

    itsPermissionMgr = new DynamicPermissionMgr(Manifest.permission.WRITE_EXTERNAL_STORAGE, this,
            REQUEST_STORAGE_PERM, REQUEST_APP_SETTINGS, "com.jefftharris.passwdsafe", R.id.reload,
            R.id.app_settings);
    showFiles(true, savedInstanceState);
    if (itsTitle == null) {
        itsTitle = getTitle();
    }
}