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.klinker.android.twitter.services.SendTweet.java

@Override
public int onStartCommand(Intent intent, int i, int x) {

    final Context context = this;
    final AppSettings settings = AppSettings.getInstance(this);

    try {/*from   w  w  w .java 2 s .  c om*/
        if (intent == null) {
            return START_NOT_STICKY;
        }
    } catch (Exception e) {
        // null pointer... what the hell
    }
    // set up the tweet from the intent
    message = intent.getStringExtra("message");
    tweetId = intent.getLongExtra("tweet_id", 0l);
    remainingChars = intent.getIntExtra("char_remaining", 0);
    pwiccer = intent.getBooleanExtra("pwiccer", false);
    attachedUri = intent.getStringExtra("attached_uri");

    if (attachedUri == null) {
        attachedUri = "";
    }

    sendingNotification();

    new Thread(new Runnable() {
        @Override
        public void run() {
            boolean sent = sendTweet(settings, context);

            if (sent) {
                finishedTweetingNotification();
            } else {
                makeFailedNotification(message, settings);
            }

            finished = true;

            stopSelf();
        }
    }).start();

    // if it takes longer than 2 mins to preform the sending, then something is wrong and we will just shut it down.
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            if (!finished) {
                stopForeground(true);
                makeFailedNotification(message, settings);
                stopSelf();
            }
        }
    }, 120000);

    return START_STICKY;
}

From source file:cn.ucai.superwechat.ui.MainActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    showExceptionDialogFromIntent(intent);
    //// FIXME: 2017/4/7 ??,Activity?,???,resume()
    boolean isChat = intent.getBooleanExtra(I.IS_FROM_CHAT, false);
    if (isChat) {
        //??,?/* ww w .j av a2  s. c  o  m*/
        layoutTabhost.setChecked(0);
        layoutViewpage.setCurrentItem(0);
    } else {

    }
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

public void processIntent(Intent intent) {
    // switch to timer setup view
    if (intent.getBooleanExtra(GOTO_SETUP_VIEW, false)) {
        gotoSetupView();//from ww  w .j  a v  a2  s .  co m
    }
}

From source file:ch.uzh.supersede.feedbacklibrary.FeedbackActivity.java

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

    UserManager userManager = (UserManager) getApplicationContext().getSystemService(Context.USER_SERVICE);
    if (userManager.isUserAGoat()) {
        Log.v(TAG, "The user IS a goat and subject to teleportations");
    } else {//from   ww  w  .  ja  va 2  s .c  o m
        Log.v(TAG, "The user IS NOT a goat and subject to teleportations");
    }

    Intent intent = getIntent();
    // Get the default image path for the screenshot if present
    defaultImagePath = intent.getStringExtra(DEFAULT_IMAGE_PATH);
    // Get the configuration type
    isPush = intent.getBooleanExtra(IS_PUSH_STRING, true);
    // Get values related to a pull configuration
    selectedPullConfigurationIndex = intent.getLongExtra(SELECTED_PULL_CONFIGURATION_INDEX_STRING, -1);
    String jsonString = intent.getStringExtra(JSON_CONFIGURATION_STRING);

    // Initialization based on the type of configuration, i.e., if it is push or pull
    language = intent.getStringExtra(EXTRA_KEY_LANGUAGE);
    baseURL = intent.getStringExtra(EXTRA_KEY_BASE_URL);
    if (!isPush && selectedPullConfigurationIndex != -1 && jsonString != null) {
        // The feedback activity is started on behalf of a triggered pull configuration
        Log.v(TAG, "The feedback activity is started via a PULL configuration");

        // Save the current configuration under FeedbackActivity.CONFIGURATION_DIR}/FeedbackActivity.JSON_CONFIGURATION_FILE_NAME
        Utils.saveStringContentToInternalStorage(getApplicationContext(), CONFIGURATION_DIR,
                JSON_CONFIGURATION_FILE_NAME, jsonString, MODE_PRIVATE);
        orchestratorConfigurationItem = new Gson().fromJson(jsonString, OrchestratorConfigurationItem.class);
        initModel();
        initView();
    } else {
        // The feedback activity is started on behalf of the user
        Log.v(TAG, "The feedback activity is started via a PUSH configuration");

        // TODO: remove before release
        //initOfflineConfiguration();

        // TODO: uncomment before release
        // Get the application id and language
        init(intent.getLongExtra(EXTRA_KEY_APPLICATION_ID, -1L), baseURL, language);
    }
}

From source file:com.amaze.carbonfilemanager.services.CopyService.java

@Override
public int onStartCommand(Intent intent, int flags, final int startId) {
    Bundle b = new Bundle();
    ArrayList<BaseFile> files = intent.getParcelableArrayListExtra(TAG_COPY_SOURCES);
    String targetPath = intent.getStringExtra(TAG_COPY_TARGET);
    int mode = intent.getIntExtra(TAG_COPY_OPEN_MODE, OpenMode.UNKNOWN.ordinal());
    final boolean move = intent.getBooleanExtra(TAG_COPY_MOVE, false);

    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    b.putInt(TAG_COPY_START_ID, startId);
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.setAction(Intent.ACTION_MAIN);
    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
    mBuilder = new NotificationCompat.Builder(c);
    mBuilder.setContentIntent(pendingIntent);
    mBuilder.setContentTitle(getResources().getString(R.string.copying))
            .setSmallIcon(R.drawable.ic_content_copy_white_36dp);

    startForeground(Integer.parseInt("456" + startId), mBuilder.build());

    b.putBoolean(TAG_COPY_MOVE, move);//from  www  .j  av a 2s. co  m
    b.putString(TAG_COPY_TARGET, targetPath);
    b.putInt(TAG_COPY_OPEN_MODE, mode);
    b.putParcelableArrayList(TAG_COPY_SOURCES, files);

    //going async
    new DoInBackground().execute(b);

    // If we get killed, after returning from here, restart
    return START_STICKY;
}

From source file:ch.uzh.supersede.feedbacklibrary.AnnotateImageActivity.java

@SuppressWarnings("unchecked")
private void initAnnotations(Intent intent) {
    RelativeLayout relativeLayout = (RelativeLayout) findViewById(
            R.id.supersede_feedbacklibrary_annotate_image_layout);
    if (relativeLayout != null) {
        if (intent.getBooleanExtra(Utils.EXTRA_KEY_HAS_STICKER_ANNOTATIONS, false)) {
            HashMap<Integer, String> allStickerAnnotations = (HashMap<Integer, String>) intent
                    .getSerializableExtra(Utils.EXTRA_KEY_ALL_STICKER_ANNOTATIONS);
            for (Map.Entry<Integer, String> entry : allStickerAnnotations.entrySet()) {
                // Array will be of length 6 --> imageResourceId, x, y, width, height, rotation
                String[] split = entry.getValue().split(Utils.SEPARATOR);
                StickerAnnotationImageView stickerAnnotationImageView = addSticker(Integer.valueOf(split[0]));
                if (stickerAnnotationImageView != null) {
                    stickerAnnotationImageView.setX(Float.valueOf(split[1]));
                    stickerAnnotationImageView.setY(Float.valueOf(split[2]));
                    stickerAnnotationImageView.getLayoutParams().width = Integer.valueOf(split[3]);
                    stickerAnnotationImageView.getLayoutParams().height = Integer.valueOf(split[4]);
                    stickerAnnotationImageView.setRotation(Float.valueOf(split[5]));
                }/* w  w w  .j a va 2  s  .  c  om*/
            }
        }
        if (intent.getBooleanExtra(Utils.EXTRA_KEY_HAS_TEXT_ANNOTATIONS, false)) {
            HashMap<Integer, String> allTextAnnotations = (HashMap<Integer, String>) intent
                    .getSerializableExtra(Utils.EXTRA_KEY_ALL_TEXT_ANNOTATIONS);
            SortedSet<Integer> keys = new TreeSet<>(allTextAnnotations.keySet());
            for (Integer key : keys) {
                // Array will be of length 4 --> annotationText, imageResourceId, x, y
                String[] split = (allTextAnnotations.get(key)).split(Utils.SEPARATOR);
                TextAnnotationImageView textAnnotationImageView = addTextAnnotation(Integer.valueOf(split[1]));
                if (textAnnotationImageView != null) {
                    textAnnotationImageView.setAnnotationInputText(split[0]);
                    textAnnotationImageView.setX(Float.valueOf(split[2]));
                    textAnnotationImageView.setY(Float.valueOf(split[3]));
                }
            }
        }
        hideAllControlItems(relativeLayout);
    }
}

From source file:com.concentricsky.android.khanacademy.data.KADataService.java

/**
 * Used for long-running operations including library updates and video downloads.
 * //  w w w.  j  ava2 s.  c  om
 */
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    Log.i("KADataService", "Received start id " + startId + ": " + intent);

    PendingIntent pendingIntent = null;
    if (intent.hasExtra(Intent.EXTRA_INTENT)) {
        // TODO : use this intent. It needs to be called with the results of requestLibraryUpdate (so far)
        pendingIntent = intent.getParcelableExtra(Intent.EXTRA_INTENT);
    }

    if (ACTION_LIBRARY_UPDATE.equals(intent.getAction())) {
        requestLibraryUpdate(startId, pendingIntent, intent.getBooleanExtra(EXTRA_FORCE, false));
        return START_REDELIVER_INTENT;
    }

    if (ACTION_UPDATE_DOWNLOAD_STATUS.equals(intent.getAction())) {
        Log.d(LOG_TAG, "update download status");
        updateDownloadStatus(intent, pendingIntent, startId);
        return START_REDELIVER_INTENT;
    }

    /*
    START_NOT_STICKY
    Do not recreate the service, unless there are pending intents to deliver. This is the 
    safest option to avoid running your service when not necessary and when your application 
    can simply restart any unfinished jobs.
    START_STICKY
    Recreate the service and call onStartCommand(), but do not redeliver the last intent. 
    Instead, the system calls onStartCommand() with a null intent, unless there were pending 
    intents to start the service, in which case, those intents are delivered. This is suitable 
    for media players (or similar services) that are not executing commands, but running 
    indefinitely and waiting for a job.
    START_REDELIVER_INTENT
    Recreate the service and call onStartCommand() with the last intent that was delivered 
    to the service. Any pending intents are delivered in turn. This is suitable for services 
    that are actively performing a job that should be immediately resumed, such as downloading a file.
     */

    // If we reach this point, the intent has some unknown action, so just ignore it and stop.
    this.stopSelfResult(startId);
    return START_NOT_STICKY;
}

From source file:com.mobicage.rogerthat.plugins.messaging.MessagingActivity.java

private void processMessageUpdatesIntent(final Intent intent) {
    final String url = intent.getDataString();
    if (intent.getBooleanExtra(HomeActivity.INTENT_PROCESSED, false))
        return;//from w w w  .j  a v a  2s.  c  o  m
    if (url != null) {
        ActivityUtils.goToMessagingActivity(this, false, null);
        processUrl(url);
    } else if (intent.hasExtra(HomeActivity.INTENT_KEY_LAUNCHINFO)) {
        String value = intent.getStringExtra(HomeActivity.INTENT_KEY_LAUNCHINFO);
        if (HomeActivity.INTENT_VALUE_SHOW_FRIENDS.equals(value)) {
            // goToUserFriendsActivity();

        } else if (HomeActivity.INTENT_VALUE_SHOW_MESSAGES.equals(value)) {
            ActivityUtils.goToMessagingActivity(this, false, null);

        } else if (HomeActivity.INTENT_VALUE_SHOW_NEW_MESSAGES.equals(value)
                || HomeActivity.INTENT_VALUE_SHOW_UPDATED_MESSAGES.equals(value)) {
            if (intent.hasExtra(HomeActivity.INTENT_KEY_MESSAGE)) {
                if (!App.getContext().getPinLockMgr().canContinueToActivity()) {
                    mPendingIntent = intent;
                    return;
                }

                String messageKey = intent.getStringExtra(HomeActivity.INTENT_KEY_MESSAGE);
                goToMessageDetail(messageKey);
            } else {
                ActivityUtils.goToMessagingActivity(this, false, null);
            }

        } else if (HomeActivity.INTENT_VALUE_SHOW_SCANTAB.equals(value)) {
            ActivityUtils.goToScanActivity(this, false, null);
        } else {
            L.bug("Unexpected (key, value) for HomeActivity intent: (" + HomeActivity.INTENT_KEY_LAUNCHINFO
                    + ", " + value + ")");
        }
    }
    intent.putExtra(HomeActivity.INTENT_PROCESSED, true);
}

From source file:com.conferenceengineer.android.iosched.ui.SessionDetailFragment.java

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

    final Intent intent = BaseActivity.fragmentArgumentsToIntent(getArguments());
    mSessionUri = intent.getData();//from   w  w w .j a  va 2  s  .  c  o m

    if (mSessionUri == null) {
        return;
    }

    mSessionId = ScheduleContract.Sessions.getSessionId(mSessionUri);

    mVariableHeightHeader = intent.getBooleanExtra(EXTRA_VARIABLE_HEIGHT_HEADER, false);

    LoaderManager manager = getLoaderManager();
    manager.restartLoader(SessionsQuery._TOKEN, null, this);
    manager.restartLoader(SpeakersQuery._TOKEN, null, this);

    setHasOptionsMenu(true);
}

From source file:com.nononsenseapps.feeder.ui.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent i = getIntent();
    if (i != null) {
        mShouldFinishBack = i.getBooleanExtra(SHOULD_FINISH_BACK, false);
    }/*  www .j  ava 2s .c  o m*/

    mLPreviewUtils = LPreviewUtils.getInstance(this);
    mThemedStatusBarColor = getResources().getColor(R.color.primary_dark);

    setNightBackground();
    // Add account and enable sync - if not done before
    RssContentProvider.SetupSync(this);
}