Example usage for android.content Intent getIntExtra

List of usage examples for android.content Intent getIntExtra

Introduction

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

Prototype

public int getIntExtra(String name, int defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.afollestad.polar.ui.MainActivity.java

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override/*from  ww  w . ja v  a 2  s  .c  om*/
public void onActivityReenter(int resultCode, Intent data) {
    super.onActivityReenter(resultCode, data);

    isReentering = true;
    reenterPos = data.getIntExtra(STATE_CURRENT_POSITION, 0);

    WallpapersFragment frag = (WallpapersFragment) getFragmentManager()
            .findFragmentByTag("page:" + mPager.getCurrentItem());
    final RecyclerView recyclerView = frag.getRecyclerView();
    if (recyclerView != null) {
        postponeEnterTransition();
        recyclerView.scrollToPosition(reenterPos);
        recyclerView.post(new Runnable() {
            @Override
            public void run() {
                recyclerView.getViewTreeObserver()
                        .addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
                            @Override
                            public boolean onPreDraw() {
                                recyclerView.getViewTreeObserver().removeOnPreDrawListener(this);

                                startPostponedEnterTransition();
                                return true;
                            }
                        });
            }
        });
    }
}

From source file:com.appsimobile.appsii.module.home.appwidget.WidgetChooserActivity.java

@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {

    // Handle binding app widgets
    final int pendingAddWidgetId = mPendingAddWidgetId;
    if (requestCode == REQUEST_BIND_APPWIDGET) {
        final int appWidgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
        if (resultCode == RESULT_CANCELED) {
            mAppWidgetHost.deleteAppWidgetId(mPendingAddWidgetId);
        } else if (resultCode == RESULT_OK) {
            onAppWidgetSelected(appWidgetId, mSelectedAppWidgetProviderInfo);

        }//from  ww w.j  a  va  2  s  .c  o  m
        return;
    }

    // handle configuration of app-widgets
    boolean isAppWidgetConfig = requestCode == REQUEST_CONFIGURE_APPWIDGET;
    if (isAppWidgetConfig) {
        int widgetId = data != null ? data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;

        // get the appWidgetId falling back to the pendingId
        final int appWidgetId;
        if (widgetId < 0) {
            appWidgetId = pendingAddWidgetId;
        } else {
            appWidgetId = widgetId;
        }

        // The appwidget has been configured. or the user cancelled the process.
        // When cancelled delete the app-widget-id and clear the pending id.
        if (appWidgetId < 0 || resultCode == RESULT_CANCELED) {
            Log.e("WidgetChooser", "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not "
                    + "returned from the widget configuration activity.");
            mAppWidgetHost.deleteAppWidgetId(mPendingAddWidgetId);
            mPendingAddWidgetId = -1;
        } else {
            // save the widget id to the cell.
            finishAndSaveWidgetToCell(appWidgetId);
        }
        return;
    }
    super.onActivityResult(requestCode, resultCode, data);

}

From source file:com.android.managedprovisioning.DeviceOwnerProvisioningActivity.java

private void handleProvisioningIntent(Intent intent) {
    String action = intent.getAction();
    if (action.equals(DeviceOwnerProvisioningService.ACTION_PROVISIONING_SUCCESS)) {
        if (DEBUG)
            ProvisionLogger.logd("Successfully provisioned");
        onProvisioningSuccess();/* w  w  w.j ava  2s .  c o m*/
    } else if (action.equals(DeviceOwnerProvisioningService.ACTION_PROVISIONING_ERROR)) {
        int errorMessageId = intent.getIntExtra(DeviceOwnerProvisioningService.EXTRA_USER_VISIBLE_ERROR_ID_KEY,
                R.string.device_owner_error_general);
        boolean factoryResetRequired = intent
                .getBooleanExtra(DeviceOwnerProvisioningService.EXTRA_FACTORY_RESET_REQUIRED, true);

        if (DEBUG) {
            ProvisionLogger.logd("Error reported with code " + getResources().getString(errorMessageId));
        }
        error(errorMessageId, factoryResetRequired);
    } else if (action.equals(DeviceOwnerProvisioningService.ACTION_PROGRESS_UPDATE)) {
        int progressMessage = intent.getIntExtra(DeviceOwnerProvisioningService.EXTRA_PROGRESS_MESSAGE_ID_KEY,
                -1);
        if (DEBUG) {
            ProvisionLogger
                    .logd("Progress update reported with code " + getResources().getString(progressMessage));
        }
        if (progressMessage >= 0) {
            progressUpdate(progressMessage);
        }
    }
}

From source file:com.androidinspain.deskclock.alarms.AlarmStateManager.java

public static void handleIntent(Context context, Intent intent) {
    final String action = intent.getAction();
    LogUtils.v("AlarmStateManager received intent " + intent);
    if (CHANGE_STATE_ACTION.equals(action)) {
        Uri uri = intent.getData();/* w  ww.j  a  v a  2  s. c o m*/
        AlarmInstance instance = AlarmInstance.getInstance(context.getContentResolver(),
                AlarmInstance.getId(uri));
        if (instance == null) {
            LogUtils.e("Can not change state for unknown instance: " + uri);
            return;
        }

        int globalId = DataModel.getDataModel().getGlobalIntentId();
        int intentId = intent.getIntExtra(ALARM_GLOBAL_ID_EXTRA, -1);
        int alarmState = intent.getIntExtra(ALARM_STATE_EXTRA, -1);
        if (intentId != globalId) {
            LogUtils.i("IntentId: " + intentId + " GlobalId: " + globalId + " AlarmState: " + alarmState);
            // Allows dismiss/snooze requests to go through
            if (!intent.hasCategory(ALARM_DISMISS_TAG) && !intent.hasCategory(ALARM_SNOOZE_TAG)) {
                LogUtils.i("Ignoring old Intent");
                return;
            }
        }

        if (intent.getBooleanExtra(FROM_NOTIFICATION_EXTRA, false)) {
            if (intent.hasCategory(ALARM_DISMISS_TAG)) {
                Events.sendAlarmEvent(com.androidinspain.deskclock.R.string.action_dismiss,
                        com.androidinspain.deskclock.R.string.label_notification);
            } else if (intent.hasCategory(ALARM_SNOOZE_TAG)) {
                Events.sendAlarmEvent(com.androidinspain.deskclock.R.string.action_snooze,
                        com.androidinspain.deskclock.R.string.label_notification);
            }
        }

        if (alarmState >= 0) {
            setAlarmState(context, instance, alarmState);
        } else {
            registerInstance(context, instance, true);
        }
    } else if (SHOW_AND_DISMISS_ALARM_ACTION.equals(action)) {
        Uri uri = intent.getData();
        AlarmInstance instance = AlarmInstance.getInstance(context.getContentResolver(),
                AlarmInstance.getId(uri));

        if (instance == null) {
            LogUtils.e("Null alarminstance for SHOW_AND_DISMISS");
            // dismiss the notification
            final int id = intent.getIntExtra(AlarmNotifications.EXTRA_NOTIFICATION_ID, -1);
            if (id != -1) {
                NotificationManagerCompat.from(context).cancel(id);
            }
            return;
        }

        long alarmId = instance.mAlarmId == null ? Alarm.INVALID_ID : instance.mAlarmId;
        final Intent viewAlarmIntent = Alarm.createIntent(context, DeskClock.class, alarmId)
                .putExtra(AlarmClockFragment.SCROLL_TO_ALARM_INTENT_EXTRA, alarmId)
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        // Open DeskClock which is now positioned on the alarms tab.
        context.startActivity(viewAlarmIntent);

        deleteInstanceAndUpdateParent(context, instance);
    }
}

From source file:com.lepin.activity.MyLoveCarActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (resultCode == RESULT_OK && requestCode == 5) {
        String cartype = data.getStringExtra("cartype");
        carTypeId = String.valueOf(data.getIntExtra("typeId", 0));
        mlType.setText(cartype);/*w  ww  . j  a  v  a 2s .co  m*/
    }
    if (resultCode == 10 && requestCode == 10) {
        loadCarInfo();
    }
}

From source file:com.kiwiteam.nomiddleman.LargeGroupActivity.java

public void initTourPage(Intent intent) {
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ratings.clear();/*from  w w  w  .j  a  v a 2 s.c o m*/
    tourRatingsA.clear();
    tourSessionsA.clear();

    tourID = intent.getIntExtra("tourId", -1);

    if (tourID == -1) {
        finish();
    } else {
        query = tourID;
        System.out.println("Index " + query);
        new GetTourPage().execute();
        //tour = conn.getTourInformation(tourID);
    }
}

From source file:com.projectgoth.mywebrtcdemo.ConnectActivity.java

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

    // Get setting keys.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    keyprefVideoCallEnabled = getString(R.string.pref_videocall_key);
    keyprefResolution = getString(R.string.pref_resolution_key);
    keyprefFps = getString(R.string.pref_fps_key);
    keyprefCaptureQualitySlider = getString(R.string.pref_capturequalityslider_key);
    keyprefVideoBitrateType = getString(R.string.pref_startvideobitrate_key);
    keyprefVideoBitrateValue = getString(R.string.pref_startvideobitratevalue_key);
    keyprefVideoCodec = getString(R.string.pref_videocodec_key);
    keyprefHwCodecAcceleration = getString(R.string.pref_hwcodec_key);
    keyprefCaptureToTexture = getString(R.string.pref_capturetotexture_key);
    keyprefAudioBitrateType = getString(R.string.pref_startaudiobitrate_key);
    keyprefAudioBitrateValue = getString(R.string.pref_startaudiobitratevalue_key);
    keyprefAudioCodec = getString(R.string.pref_audiocodec_key);
    keyprefNoAudioProcessingPipeline = getString(R.string.pref_noaudioprocessing_key);
    keyprefAecDump = getString(R.string.pref_aecdump_key);
    keyprefOpenSLES = getString(R.string.pref_opensles_key);
    keyprefDisplayHud = getString(R.string.pref_displayhud_key);
    keyprefTracing = getString(R.string.pref_tracing_key);
    keyprefRoomServerUrl = getString(R.string.pref_room_server_url_key);
    keyprefRoom = getString(R.string.pref_room_key);
    keyprefRoomList = getString(R.string.pref_room_list_key);

    setContentView(R.layout.activity_connect);

    roomEditText = (EditText) findViewById(R.id.room_edittext);
    roomEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override/*from  w ww  .j  av  a2s. c  o m*/
        public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
            if (i == EditorInfo.IME_ACTION_DONE) {
                addRoomButton.performClick();
                return true;
            }
            return false;
        }
    });
    roomEditText.requestFocus();

    roomListView = (ListView) findViewById(R.id.room_listview);
    roomListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    addRoomButton = (ImageButton) findViewById(R.id.add_room_button);
    addRoomButton.setOnClickListener(addRoomListener);
    removeRoomButton = (ImageButton) findViewById(R.id.remove_room_button);
    removeRoomButton.setOnClickListener(removeRoomListener);
    connectButton = (ImageButton) findViewById(R.id.connect_button);
    connectButton.setOnClickListener(connectListener);
    connectLoopbackButton = (ImageButton) findViewById(R.id.connect_loopback_button);
    connectLoopbackButton.setOnClickListener(connectListener);

    // If an implicit VIEW intent is launching the app, go directly to that URL.
    final Intent intent = getIntent();
    if ("android.intent.action.VIEW".equals(intent.getAction()) && !commandLineRun) {
        commandLineRun = true;
        boolean loopback = intent.getBooleanExtra(CallActivity.EXTRA_LOOPBACK, false);
        int runTimeMs = intent.getIntExtra(CallActivity.EXTRA_RUNTIME, 0);
        String room = sharedPref.getString(keyprefRoom, "");
        roomEditText.setText(room);
        connectToRoom(loopback, runTimeMs);
        return;
    }
}

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

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

    buildCustomActionBar();//from w  w w  .ja  v a  2s  .com

    if (savedInstanceState == null) {
        // create and attach our model fragment.
        getSupportFragmentManager().beginTransaction().add(new SurveyModelHolder(), "model").commit();
    } else {
        gpsTrackingOn = savedInstanceState.getBoolean(GPS_TRACKING_BUNDLE_KEY);
        gpsTimeoutCount = savedInstanceState.getInt(GPS_TIMEOUT_BUNDLE_KEY);
    }

    pagerAdapter = new SurveyPagerAdapter(getSupportFragmentManager());
    pager = (ValidatingViewPager) findViewById(R.id.surveyPager);
    leftArrow = findViewById(R.id.leftArrow);
    rightArrow = findViewById(R.id.rightArrow);
    Intent i = getIntent();
    int speciesId = i.getIntExtra(CollectSurveyData.SPECIES, 0);
    if (speciesId > 0) {
        SpeciesDAO speciesDao = new SpeciesDAO(this);
        selectedSpecies = speciesDao.load(Species.class, speciesId);
    }

}

From source file:com.android.my.calendar.alerts.DismissAlarmsService.java

@Override
public void onHandleIntent(Intent intent) {
    if (AlertService.DEBUG) {
        Log.d(TAG, "onReceive: a=" + intent.getAction() + " " + intent.toString());
    }//from   w  w w. j  a va 2  s .co  m

    long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1);
    long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1);
    long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1);
    long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY);
    long[] eventStarts = intent.getLongArrayExtra(AlertUtils.EVENT_STARTS_KEY);
    int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1);
    List<AlarmId> alarmIds = new LinkedList<AlarmId>();

    Uri uri = CalendarAlerts.CONTENT_URI;
    String selection;

    // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms
    if (eventId != -1) {
        alarmIds.add(new AlarmId(eventId, eventStart));
        selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID
                + "=" + eventId;
    } else if (eventIds != null && eventIds.length > 0 && eventStarts != null
            && eventIds.length == eventStarts.length) {
        selection = buildMultipleEventsQuery(eventIds);
        for (int i = 0; i < eventIds.length; i++) {
            alarmIds.add(new AlarmId(eventIds[i], eventStarts[i]));
        }
    } else {
        // NOTE: I don't believe that this ever happens.
        selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED;
    }

    GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds);

    ContentResolver resolver = getContentResolver();
    ContentValues values = new ContentValues();
    values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED);
    resolver.update(uri, values, selection, null);

    // Remove from notification bar.
    if (notificationId != -1) {
        NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(notificationId);
    }

    if (SHOW_ACTION.equals(intent.getAction())) {
        // Show event on Calendar app by building an intent and task stack to start
        // EventInfoActivity with AllInOneActivity as the parent activity rooted to home.
        Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd);

        TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i)
                .startActivities();
    }
}

From source file:com.kiddobloom.bucketlist.AuthenticatorActivity.java

/**
 * {@inheritDoc}//w ww .ja  v  a 2s  .c om
 */
@Override
public void onCreate(Bundle icicle) {

    Intent intent = getIntent();
    bucketListTab = intent.getIntExtra("com.kiddobloom.bucketlist.current_tab", 0);

    //Log.d("tagaa", "authenticator activity oncreate - bucketListTab: " + bucketListTab);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    super.onCreate(icicle);
    setProgressBarIndeterminateVisibility(false);

    uiHelper = new UiLifecycleHelper(this, callback);
    uiHelper.onCreate(icicle);

    //getActionBar().setTitle(getResources().getString(R.string.app_name));
    getActionBar().setTitle("Bucket List");
    getActionBar().setSubtitle("by kiddoBLOOM");

    sp = getSharedPreferences(getString(R.string.pref_name), MODE_PRIVATE);
    am = AccountManager.get(this);
    myApp = (MyApplication) getApplication();

    // reset the sync flag to trigger re-sync
    saveInitialSynced(false);
}