List of usage examples for android.content Intent getIntExtra
public int getIntExtra(String name, int defaultValue)
From source file:ch.luklanis.esscan.history.HistoryActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == RESULT_OK && requestCode == DETAILS_REQUEST_CODE) { if (intent.hasExtra(Intents.History.ITEM_NUMBER)) { int position = intent.getIntExtra(Intents.History.ITEM_NUMBER, -1); HistoryItem item = mHistoryManager.buildHistoryItem(position); this.historyFragment.updatePosition(position, item); }/*from w w w . ja va 2 s. c om*/ } }
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);/*from ww w.ja v a 2s. co 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 (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:cc.arduino.mvd.services.HttpService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i("ELEPHANT", "STARTING HTTPSERVICE"); if (!started) { url = intent.getStringExtra(MvdServiceReceiver.EXTRA_SERVICE_URL); // Make sure the url ends with a slash if (!url.endsWith("/")) { url = url + "/"; }// w w w. java 2s.co m delay = intent.getIntExtra(MvdServiceReceiver.EXTRA_SERVICE_DELAY, 5000); startGetRequests(delay); started = true; if (DEBUG) { Log.d(TAG, TAG + " started."); } } return START_STICKY; }
From source file:com.appunite.appunitevideoplayer.PlayerActivity.java
@Override public void onResume() { super.onResume(); Intent intent = getIntent(); final String videoUrl = intent.getStringExtra(VIDEO_URL_EXTRA); contentUri = Uri.parse(videoUrl);//from ww w . j a v a2 s. c o m contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA, inferContentType(contentUri, videoUrl)); configureSubtitleView(); if (player == null) { preparePlayer(true); } else { player.setBackgrounded(false); } }
From source file:at.jclehner.rxdroid.NotificationReceiver.java
@Override public void onReceive(Context context, Intent intent) { if (intent == null) return;/*from w w w .ja v a 2 s . c o m*/ Settings.init(); Database.init(); final boolean isAlarmRepetition = intent.getBooleanExtra(EXTRA_IS_ALARM_REPETITION, false); final int doseTime = intent.getIntExtra(EXTRA_DOSE_TIME, Schedule.TIME_INVALID); if (doseTime != Schedule.TIME_INVALID) { if (!isAlarmRepetition) { final Date date = (Date) intent.getSerializableExtra(EXTRA_DATE); final boolean isDoseTimeEnd = intent.getBooleanExtra(EXTRA_IS_DOSE_TIME_END, false); final String eventName = isDoseTimeEnd ? "onDoseTimeEnd" : "onDoseTimeBegin"; sEventMgr.post(eventName, EVENT_HANDLER_ARG_TYPES, date, doseTime); } } mContext = context; mAlarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mDoPostSilent = intent.getBooleanExtra(EXTRA_SILENT, false); mForceUpdate = isAlarmRepetition ? true : intent.getBooleanExtra(EXTRA_FORCE_UPDATE, false); mAllDrugs = Database.getAll(Drug.class); rescheduleAlarms(); updateCurrentNotifications(); }
From source file:com.brewcrewfoo.performance.fragments.BatteryInfo.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); context = getActivity();//from w w w. j av a 2s .c o m mPreferences = PreferenceManager.getDefaultSharedPreferences(context); batteryInfoReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { //int health= intent.getIntExtra(BatteryManager.EXTRA_HEALTH,0); //String technology= intent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY); //boolean present= intent.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT); //int rawvoltage= intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE,0); plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0); int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, 0); int lev = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0); int temperature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0); level = lev * scale / 100; mbattery_percent.setText(level + "%"); if (new File(BAT_VOLT_PATH).exists()) { int volt = Integer.parseInt(Helpers.readOneLine(BAT_VOLT_PATH)); if (volt > 5000) volt = (int) Math.round(volt / 1000.0);// in microvolts mbattery_volt.setText(volt + " mV"); } switch ((int) Math.ceil(level / 20.0)) { case 0: mBattIcon.setImageResource(R.drawable.battery_0); break; case 1: mBattIcon.setImageResource(R.drawable.battery_1); break; case 2: mBattIcon.setImageResource(R.drawable.battery_2); break; case 3: mBattIcon.setImageResource(R.drawable.battery_3); break; case 4: mBattIcon.setImageResource(R.drawable.battery_4); break; case 5: mBattIcon.setImageResource(R.drawable.battery_5); break; } mbattery_status.setText( (temperature / 10) + "C " + getResources().getStringArray(R.array.batt_status)[status]); } }; //getActivity().registerReceiver(batteryInfoReceiver,new IntentFilter(Intent.ACTION_BATTERY_CHANGED) ); setRetainInstance(true); setHasOptionsMenu(true); }
From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { //FINAL DEL SERVICIO case 1:// w ww . ja va 2 s . c o m if (resultCode == getActivity().RESULT_OK) { finishRequestParams.add("reportNumber", String.valueOf(data.getIntExtra("requestReportNumber", 0))); finishRequestParams.add("licencia", configuration.getLicense()); finishRequestParams.add("movil", configuration.getMobile()); finishRequestParams.add("viajeID", String.valueOf(serv.getIdServicio())); finishRequestParams.add("motivoID", String.valueOf(data.getIntExtra("idMotivo", 0))); finishRequestParams.add("diagnosticoID", String.valueOf(data.getIntExtra("idDiagnostico", 0))); finishRequestParams.add("observaciones", data.getStringExtra("observaciones")); finishRequestParams.add("copago", String.valueOf(data.getIntExtra("copago", 0))); finishRequestParams.add("derivationTime", String.valueOf(data.getStringExtra("derivationTime"))); try { finishRequestParams.put("audio", new File(String.valueOf(data.getStringExtra("audio")))); } catch (FileNotFoundException e) { } if (configuration.isRequestAttachImage()) { showUploadPhotoPopup(true); } else { finishIncident(); } } else { showToast("No se finaliz el servicio"); } break; //CANCELACION DEL SERVICIO case 2: if (resultCode == getActivity().RESULT_OK) { String motivoCancelacion = data.getStringExtra("motivoCancelacion"); RequestParams rp = new RequestParams(); rp.add("licencia", configuration.getLicense()); rp.add("movil", configuration.getMobile()); rp.add("viajeID", String.valueOf(serv.getIdServicio())); rp.add("observaciones", motivoCancelacion); try { doAsyncTaskPostServicio(configuration.getUrl() + "/actions/setCancelacionServicio", "Cancelando servicio...", rp); } catch (JSONException e) { showToast(e.getMessage()); } } else { showToast("No se cancel el servicio"); } break; case REQUEST_TAKE_PHOTO: if (resultCode != 0) { try { DetalleServicioActivity activity = (DetalleServicioActivity) getActivity(); File f = new File(activity.getCurrentPhotoPath()); boolean isFinishingService = activity.getIsFinishingService(); uploadPhoto(f, isFinishingService); } catch (Exception ex) { showToast(ex.getMessage()); } } break; } }
From source file:de.stadtrallye.rallyesoft.MainActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Log.i(THIS, "Receiving Intent"); if (intent != null && intent.hasExtra(Std.TAB)) { Log.i(THIS, "Receiving Intent with Tab"); if (intent.getStringExtra(Std.TAB).equals(Std.CHATROOM)) { int chatroom = intent.getIntExtra(Std.CHATROOM, -1); int chatID = intent.getIntExtra(Std.CHAT_ID, -1); Bundle b = new Bundle(); b.putInt(Std.CHATROOM, chatroom); b.putInt(Std.CHAT_ID, chatID); tabManager.setArguments(RallyeTabManager.TAB_CHAT, b); tabManager.switchToTab(RallyeTabManager.TAB_CHAT); }//w w w. ja v a2 s. c o m } }
From source file:com.dashihui.afford.ui.activity.server.AtyFragmentServerTime.java
@Override public void onSuccess(EtySendToUI beanSendUI) { LogUtils.e("onSuccess==============>" + beanSendUI); if (beanSendUI != null) { serverTimeList = (List<EtyServerTime>) beanSendUI.getInfo(); if (!UtilList.isEmpty(serverTimeList)) { LogUtils.e("onSuccess==============>" + serverTimeList.get(0).getDATE()); LogUtils.e("onSuccess==============>" + serverTimeList.get(0).getTITLE()); Intent intent = getIntent(); mPageAdapter = new MyPagerAdapter(getSupportFragmentManager(), serverTimeList); // ???N?? mPager.setOffscreenPageLimit(mPageAdapter.getCount()); mPager.setAdapter(mPageAdapter); final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); mPager.setPageMargin(pageMargin); mPager.setCurrentItem(intent.getIntExtra(TABCODE, 0)); mTabs.setViewPager(mPager);//from w w w . jav a2 s.c o m changeColor(currentColor); } else { LogUtils.e("onSuccess=====null=========>" + serverTimeList); } } else { LogUtils.e("onSuccess===null===========>" + beanSendUI); } }
From source file:com.chinabike.plugins.mip.activity.LocalAlbumDetail.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(FakeR.getId(this, "layout", "local_album_detail")); Intent intent = getIntent(); maximumImagesCount = intent.getIntExtra("MAX_IMAGES", 20); desiredWidth = intent.getIntExtra("WIDTH", 0); desiredHeight = intent.getIntExtra("HEIGHT", 0); quality = intent.getIntExtra("QUALITY", 100); if (!helper.isInited()) { finish();/* www . j a v a 2s. co m*/ return; } title = (TextView) findViewById(FakeR.getId(this, "id", "album_title")); finish = (TextView) findViewById(FakeR.getId(this, "id", "album_finish")); headerFinish = (TextView) findViewById(FakeR.getId(this, "id", "header_finish")); gridView = (GridView) findViewById(FakeR.getId(this, "id", "gridview")); titleBar = findViewById(FakeR.getId(this, "id", "album_title_bar")); viewpager = (AlbumViewPager) findViewById(FakeR.getId(this, "id", "albumviewpager")); pagerContainer = findViewById(FakeR.getId(this, "id", "pagerview")); mCountView = (TextView) findViewById(FakeR.getId(this, "id", "header_bar_photo_count")); viewpager.setOnPageChangeListener(pageChangeListener); viewpager.setOnSingleTapListener(this); mBackView = (ImageView) findViewById(FakeR.getId(this, "id", "header_bar_photo_back")); headerBar = findViewById(FakeR.getId(this, "id", "album_item_header_bar")); checkBox = (CheckBox) findViewById(FakeR.getId(this, "id", "checkbox")); checkBox.setOnCheckedChangeListener(this); mBackView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideViewPager(); } }); finish.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { helper.setResultOk(true); doActivityResult(); // new ResizeImagesTask().execute(fileNames.entrySet()); } }); headerFinish.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { helper.setResultOk(true); doActivityResult(); // new ResizeImagesTask().execute(fileNames.entrySet()); } }); findViewById(FakeR.getId(this, "id", "album_back")).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); folder = getIntent().getExtras().getString(ExtraKey.LOCAL_FOLDER_NAME); new Thread(new Runnable() { @Override public void run() { //??????? helper.initImage(); //? final List<LocalImageHelper.LocalFile> folders = helper.getFolder(folder); runOnUiThread(new Runnable() { @Override public void run() { if (folders != null) { currentFolder = folders; MyAdapter adapter = new MyAdapter(LocalAlbumDetail.this, folders); title.setText(folder); gridView.setAdapter(adapter); //?? if (checkedItems.size() + helper.getCurrentSize() > 0) { finish.setText(String.format("?(%d/%d)", (checkedItems.size() + helper.getCurrentSize()), maximumImagesCount)); finish.setEnabled(true); headerFinish.setText(String.format("?(%d/%d)", (checkedItems.size() + helper.getCurrentSize()), maximumImagesCount)); headerFinish.setEnabled(true); } else { finish.setText("?"); // finish.setEnabled(false); headerFinish.setText("?"); // headerFinish.setEnabled(false); } } } }); } }).start(); checkedItems = helper.getCheckedItems(); fileNames = helper.getFileNames(); helper.setResultOk(false); }