List of usage examples for android.content Intent getIntExtra
public int getIntExtra(String name, int defaultValue)
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
@Override public void onResume() { super.onResume(); mHandler = new NotifyingAsyncQueryHandler(getActivity().getContentResolver(), this); Intent intent = getSherlockActivity().getIntent(); // TODO Optimize this using savedInstanceState to avoid reload of // identical data onResume if (Intent.ACTION_VIEW.equals(intent.getAction())) { mIdPost = getIdFromUri(intent.getData()); }//from ww w. ja v a 2 s . c o m // else if ((savedInstanceState != null) // && savedInstanceState.containsKey(Const.KEY_INSTANCE_RINK_ID)) { // mRinkId = savedInstanceState.getInt(Const.KEY_INSTANCE_RINK_ID); // } else { mIdPost = intent.getIntExtra(Const.INTENT_EXTRA_POST_ID, -1); } // mUriPost = Posts.buildPostUri(Integer.toString(mIdPost)); final GregorianCalendar calendar = parkingApp.getParkingCalendar(); final int duration = parkingApp.getParkingDuration(); ((TextView) mView.findViewById(R.id.details_time_title)) .setText(ParkingTimeHelper.getTitle(this.getActivity(), calendar, duration)); }
From source file:com.actinarium.nagbox.service.NagboxService.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;/*from w w w .j a v a 2 s . c om*/ } // I know that only either of those is needed, but for the sake of nice code I'm pulling these here final Task task = intent.getParcelableExtra(EXTRA_TASK); final long id = intent.getLongExtra(EXTRA_TASK_ID, Task.NO_ID); switch (intent.getAction()) { case ACTION_UPDATE_TASK_STATUS: handleUpdateTaskStatus(task); break; case ACTION_ON_ALARM_FIRED: handleOnAlarmFired(); break; case ACTION_ON_NOTIFICATION_DISMISSED: handleOnNotificationDismissed(id); break; case ACTION_ON_NOTIFICATION_ACTION_STOP_TASK: int notificationIdToCancel = intent.getIntExtra(EXTRA_CANCEL_NOTIFICATION_ID, -1); handleStopTaskById(id, notificationIdToCancel); break; case ACTION_CREATE_TASK: handleCreateTask(task); break; case ACTION_UPDATE_TASK: handleUpdateTask(task); break; case ACTION_DELETE_TASK: handleDeleteTask(id); break; case ACTION_RESTORE_TASK: handleRestoreTask(task); break; } // Release the wake lock, if there was any. WakefulBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.honglang.zxing.CaptureActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == RESULT_OK) { if (requestCode == HISTORY_REQUEST_CODE) { int itemNumber = intent.getIntExtra(Intents.History.ITEM_NUMBER, -1); if (itemNumber >= 0) { // HistoryItem historyItem = // historyManager.buildHistoryItem(itemNumber); // decodeOrStoreSavedBitmap(null, historyItem.getResult()); }/*w w w .j a v a 2 s.c o m*/ } } //PeiCheChuKuAdd again if (requestCode == 200) { if (resultCode == RESULT_OK) { pcId = intent.getStringExtra("pcid"); Log.i("suxoyo", "3-pcid=" + pcId); } } }
From source file:com.irccloud.android.RemoteInputService.java
@Override protected void onHandleIntent(Intent intent) { boolean success = false; String sk = getSharedPreferences("prefs", 0).getString("session_key", ""); if (intent != null && sk != null && sk.length() > 0) { final String action = intent.getAction(); if (ACTION_REPLY.equals(action)) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null || intent.hasExtra("reply")) { Crashlytics.log(Log.INFO, "IRCCloud", "Got reply from RemoteInput"); String reply = remoteInput != null ? remoteInput.getCharSequence("extra_reply").toString() : intent.getStringExtra("reply"); if (reply.length() > 0 && !reply.contains("\n/") && (!reply.startsWith("/") || reply.toLowerCase().startsWith("/me ") || reply.toLowerCase().startsWith("/slap "))) { try { JSONObject o = NetworkConnection.getInstance().say(intent.getIntExtra("cid", -1), intent.getStringExtra("to"), reply, sk); success = o.getBoolean("success"); } catch (Exception e) { e.printStackTrace(); }// w w w. j a v a 2 s . c o m } NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext()) .cancel(intent.getIntExtra("bid", 0)); if (intent.hasExtra("eids")) { int bid = intent.getIntExtra("bid", -1); long[] eids = intent.getLongArrayExtra("eids"); for (int j = 0; j < eids.length; j++) { if (eids[j] > 0) { Notifications.getInstance().dismiss(bid, eids[j]); } } } if (!success) Notifications.getInstance().alert(intent.getIntExtra("bid", -1), "Sending Failed", reply.startsWith("/") ? "Please launch the IRCCloud app to send this command" : "Your message was not sent. Please try again shortly."); } else { Crashlytics.log(Log.ERROR, "IRCCloud", "RemoteInputService received no remoteinput"); } } } }
From source file:com.custom.music.MusicBrowserActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { /// M: Get the start activity tab index from intent which set by start activity, so that we can return /// result to right activity. int startActivityTab = mCurrentTab; if (data != null) { startActivityTab = data.getIntExtra(MusicUtils.START_ACTIVITY_TAB_ID, mCurrentTab); }/*w ww. j ava 2 s.co m*/ Log.i(TAG, "<onActivityResult> startActivityTab = " + startActivityTab, Log.APP); Activity startActivity = mActivityManager.getActivity(getStringId(startActivityTab)); if (startActivity == null) { return; } switch (startActivityTab) { case ARTIST_INDEX: ((ArtistAlbumBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data); break; case ALBUM_INDEX: ((AlbumBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data); break; case SONG_INDEX: ((TrackBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data); break; case PLAYLIST_INDEX: ((PlaylistBrowserActivity) startActivity).onActivityResult(requestCode, resultCode, data); break; default: break; } }
From source file:com.google.android.apps.muzei.api.MuzeiArtSource.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;// w w w . ja v a 2s .co m } String action = intent.getAction(); // TODO: permissions? if (ACTION_SUBSCRIBE.equals(action)) { processSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT), intent.getStringExtra(EXTRA_TOKEN)); } else if (ACTION_HANDLE_COMMAND.equals(action)) { int commandId = intent.getIntExtra(EXTRA_COMMAND_ID, 0); processHandleCommand(commandId, intent.getExtras()); } else if (ACTION_NETWORK_AVAILABLE.equals(action)) { processNetworkAvailable(); } }
From source file:com.insthub.O2OMobile.Activity.D1_OrderActivity.java
private void handleIntent(Intent intent) { mOrderId = intent.getIntExtra(ORDER_ID, 0); mOrderInfoModel.get(mOrderId); }
From source file:cc.mintcoin.wallet.service.BlockchainServiceImpl.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { log.info("service start command: " + intent + (intent.hasExtra(Intent.EXTRA_ALARM_COUNT) ? " (alarm count: " + intent.getIntExtra(Intent.EXTRA_ALARM_COUNT, 0) + ")" : "")); //log.info("org.bitcoin.NativeSecp256k1.enabled=" + org.bitcoin.NativeSecp256k1.enabled); if (blockChain == null) { boolean blockChainFileExists = blockChainFile.exists(); boolean tryStarting = true; if (DownloadCompleteReceiver.isDownloading(application)) { log.info("isDownloading"); DownloadCompleteReceiver.updateDownloadState(application); // it can fix itself this way tryStarting = false;//w ww . j av a 2 s . co m } else if (!blockChainFileExists) { if (DownloadCompleteReceiver.isObbAvailable(application)) { initializeBlockchainFast(); tryStarting = true; } else if (intent.getBooleanExtra(DownloadCompleteReceiver.INTENT_EXTRA_SKIP_OBB_INIT, false)) { tryStarting = true; } else { // open dialog box to ask user what to do for download Intent intent2 = new Intent(this, InitialBlockchainActivity.class); intent2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(intent2); tryStarting = false; } } if (tryStarting) { try { startBlockChain(); } catch (Error e) { stopSelf(); throw e; } } else { stopSelf(); } } String action = intent.getAction(); if (BlockchainService.ACTION_CANCEL_COINS_RECEIVED.equals(action)) { notificationCount = 0; 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()); } } return START_NOT_STICKY; }
From source file:com.provision.alarmemi.paper.fragments.SetAlarmFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { mActivity.setOnLifeCycleChangeListener(this); isChanged = isCloud = false;/*from w w w. j a v a 2 s .co m*/ // Override the default content view. root = (ViewGroup) super.onCreateView(inflater, container, bundle); final ImageView moreAlarm = (ImageView) root.findViewById(R.id.more_alarm); FragmentChangeActivity.moreAlarm = moreAlarm; moreAlarm.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (menu.isMenuShowing()) { menu.showContent(); } else { menu.showMenu(true); } } }); // Make the entire view selected when focused. moreAlarm.setOnFocusChangeListener(new View.OnFocusChangeListener() { public void onFocusChange(View v, boolean hasFocus) { v.setSelected(hasFocus); } }); addPreferencesFromResource(R.xml.alarm_prefs); myUUID = SplashActivity.myUUID; // Get each preference so we can retrieve the value later. mLabel = findPreference("label"); mLabel.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { showEditTextPreference(mLabel.getKey(), mLabel.getTitle(), mLabelText); return true; } }); Preference.OnPreferenceChangeListener preferceChangedListener = new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference p, Object newValue) { isChanged = true; return true; } }; mEnabledPref = (CheckBoxPreference) findPreference("enabled"); mEnabledPref.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (!isCloud) { isChanged = true; if ((Boolean) newValue) showCategory(); else hideCategory(); return true; } if ((Boolean) newValue) { try { tempjson = new JSONArray("[]"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } selectedDevice = ""; for (int i = 0; i < json.length(); i++) { if (UIDitems[i].toString().equals(myUUID)) checkedItems[i] = true; if (checkedItems[i]) { Map<String, String> map = new HashMap<String, String>(); map.put("name", URLDecoder.decode(items[i].toString())); map.put("uid", UIDitems[i].toString()); tempjson.put(map); selectedDevice += items[i] + ", "; } } if (!selectedDevice.equals("")) selectedDevice = selectedDevice.substring(0, selectedDevice.length() - 2); } else { try { tempjson = new JSONArray("[]"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } selectedDevice = ""; for (int i = 0; i < json.length(); i++) { if (UIDitems[i].toString().equals(myUUID)) checkedItems[i] = false; if (checkedItems[i]) { Map<String, String> map = new HashMap<String, String>(); map.put("name", URLDecoder.decode(items[i].toString())); map.put("uid", UIDitems[i].toString()); tempjson.put(map); selectedDevice += items[i] + ", "; } } if (!selectedDevice.equals("")) selectedDevice = selectedDevice.substring(0, selectedDevice.length() - 2); } mForest.setSummary(selectedDevice); isChanged = true; return true; } }); mTimePref = findPreference("time"); mVibratePref = (CheckBoxPreference) findPreference("vibrate"); mVibratePref.setOnPreferenceChangeListener(preferceChangedListener); mRepeatPref = findPreference("setRepeat"); mRepeatPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { String[] values = new String[] { DateUtils.getDayOfWeekString(Calendar.MONDAY, DateUtils.LENGTH_LONG), DateUtils.getDayOfWeekString(Calendar.TUESDAY, DateUtils.LENGTH_LONG), DateUtils.getDayOfWeekString(Calendar.WEDNESDAY, DateUtils.LENGTH_LONG), DateUtils.getDayOfWeekString(Calendar.THURSDAY, DateUtils.LENGTH_LONG), DateUtils.getDayOfWeekString(Calendar.FRIDAY, DateUtils.LENGTH_LONG), DateUtils.getDayOfWeekString(Calendar.SATURDAY, DateUtils.LENGTH_LONG), DateUtils.getDayOfWeekString(Calendar.SUNDAY, DateUtils.LENGTH_LONG) }; Intent intent = new Intent(mActivity, RepeatListPreference.class); intent.putExtra("key", mRepeatPref.getKey()); intent.putExtra("title", mRepeatPref.getTitle()); intent.putExtra("lists", values); intent.putExtra("multi", true); startActivity(intent); return true; } }); mForestName = findPreference("forest_name"); mForest = findPreference("forest"); mColorPref = (AmbilWarnaPreference) findPreference("color"); prefs = mActivity.getSharedPreferences("forest", mActivity.MODE_PRIVATE); Intent i = mActivity.setAlarmGetIntent; mId = i.getIntExtra(Alarms.ALARM_ID, -1); alarm = null; if (mId == -1) { // No alarm id means create a new alarm. alarm = new Alarm(); isChanged = true; } else { // * load alarm details from database alarm = Alarms.getAlarm(mActivity.getContentResolver(), mId); // Bad alarm, bail to avoid a NPE. if (alarm == null) { finish(); return root; } isCloud = wasCloud = alarm.cloudEnabled; } mOriginalAlarm = alarm; if (wasCloud) { try { Log.e("url", " : " + alarm.cloudName); json = new JSONArray(prefs.getString(alarm.cloudName + "_registeredDevice", "")); String cloud_uid = alarm.cloudUID; if (cloud_uid.equals("")) cloud_uid = "[]"; Log.e("url", cloud_uid); tempjson = new JSONArray(cloud_uid); items = new String[json.length()]; UIDitems = new CharSequence[json.length()]; checkedItems = new boolean[json.length()]; for (int j = 0; j < json.length(); j++) { JSONObject jsonObj = json.getJSONObject(j); items[j] = jsonObj.getString("name"); UIDitems[j] = jsonObj.getString("uid"); checkedItems[j] = alarm.cloudUID.contains(jsonObj.getString("uid")); } } catch (Exception e) { Log.e("url", e.toString()); } selectedDevice = alarm.cloudDevices; mForestName.setEnabled(false); } else { if (prefs.getString("name", "").length() > 0) { names = prefs.getString("name", "").substring(1).split("\\|"); nameCheckedIndex = -1; } else mForestName.setEnabled(false); mForest.setEnabled(false); } memi_count = alarm.memiCount; snooze_strength = alarm.snoozeStrength; snooze_count = alarm.snoozeCount; updatePrefs(mOriginalAlarm); mTimePref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { showTimePicker(); return false; } }); mForestName.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { showListPreference(mForestName.getKey(), mForestName.getTitle(), names, String.valueOf(nameCheckedIndex), false); return true; } }); mForest.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference arg0) { showListPreference(mForest.getKey(), mForest.getTitle(), items, booleanArrayToString(checkedItems), true); return true; } }); mColorPref.setOnPreferenceChangeListener(preferceChangedListener); // We have to do this to get the save/cancel buttons to highlight on // their own. ((ListView) root.findViewById(android.R.id.list)).setItemsCanFocus(true); // Attach actions to each button. View.OnClickListener back_click = new View.OnClickListener() { public void onClick(View v) { DontSaveDialog(false, null, false); } }; ImageView b = (ImageView) root.findViewById(R.id.back); b.setOnClickListener(back_click); b = (ImageView) root.findViewById(R.id.logo); b.setOnClickListener(back_click); b = (ImageView) root.findViewById(R.id.alarm_save); b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { saveAlarm(); } }); b = (ImageView) root.findViewById(R.id.alarm_delete); if (mId == -1) { b.setEnabled(false); } else { b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { deleteAlarm(); } }); } // The last thing we do is pop the time picker if this is a new alarm. if (mId == -1) { // Assume the user hit cancel mTimePickerCancelled = true; showTimePicker(); } if (!isCloud && !alarm.enabled) hideCategory(); FragmentChangeActivity.OnNotifyArrived.sendEmptyMessage(0); return root; }
From source file:com.android.calendar.EventInfoActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); // Get the info needed for the fragment Intent intent = getIntent(); int attendeeResponse = 0; mEventId = -1;// w ww. j a v a 2 s.c o m boolean isDialog = false; ArrayList<ReminderEntry> reminders = null; if (icicle != null) { mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID); mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS); mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS); attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE); isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG); reminders = Utils.readRemindersFromBundle(icicle); } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) { mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0); mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0); attendeeResponse = intent.getIntExtra("attendeeStatus", Attendees.ATTENDEE_STATUS_NONE); Uri data = intent.getData(); if (data != null) { try { List<String> pathSegments = data.getPathSegments(); int size = pathSegments.size(); if (size > 2 && "EventTime".equals(pathSegments.get(2))) { // Support non-standard VIEW intent format: // dat = // content://com.android.calendar/events/[id]/EventTime/[start]/[end] mEventId = Long.parseLong(pathSegments.get(1)); if (size > 4) { mStartMillis = Long.parseLong(pathSegments.get(3)); mEndMillis = Long.parseLong(pathSegments.get(4)); } } else { mEventId = Long.parseLong(data.getLastPathSegment()); } } catch (NumberFormatException e) { if (mEventId == -1) { // do nothing here , deal with it later } else if (mStartMillis == 0 || mEndMillis == 0) { // Parsing failed on the start or end time , make sure // the times were not // pulled from the intent's extras and reset them. mStartMillis = 0; mEndMillis = 0; } } } } if (mEventId == -1) { Log.w(TAG, "No event id"); Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show(); finish(); } // If we do not support showing full screen event info in this // configuration, // close the activity and show the event in AllInOne. Resources res = getResources(); if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen) && !res.getBoolean(R.bool.show_event_info_full_screen)) { CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis, attendeeResponse); finish(); return; } setContentView(R.layout.simple_frame_layout); // Get the fragment if exists mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame); // Remove the application title ActionBar bar = getActionBar(); if (bar != null) { bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP); } // Create a new fragment if none exists if (mInfoFragment == null) { FragmentManager fragmentManager = getSupportFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse, isDialog, (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE), reminders); ft.replace(R.id.main_frame, mInfoFragment); ft.commit(); } }