List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:awbb.droid.data.RatingActivity.java
/** * {@inheritDoc}/*from w w w . j av a2s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { // set theme ((AwbbApplication) getApplication()).applyTheme(this); // create activity super.onCreate(savedInstanceState); // data source DatabaseDataSource.create(this); DatabaseDataSource.open(); // load view setContentView(R.layout.activity_rating); viewPager = (ViewPager) findViewById(R.id.ratingPager); // get data from intent Intent intent = getIntent(); long id = intent.getLongExtra(EXTRA_RATING_ID, -1); // init if (id == -1) { rating = new Rating(); } else { rating = RatingDao.get(id); } // adapter adapter = new RatingPagerAdapter(this, getSupportFragmentManager()); viewPager.setAdapter(adapter); // action bar final ActionBar actionBar = getActionBar(); // FIXME // http://developer.android.com/training/implementing-navigation/lateral.html#horizontal-paging actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // ActionBar.TabListener tabListener = new ActionBar.TabListener() { // // @Override // public void onTabUnselected(Tab tab, FragmentTransaction ft) { // // TODO Auto-generated method stub // // } // // @Override // public void onTabSelected(Tab tab, FragmentTransaction ft) { // viewPager.setCurrentItem(tab.getPosition()); // } // // @Override // public void onTabReselected(Tab tab, FragmentTransaction ft) { // // TODO Auto-generated method stub // // } // // }; // add tabs // for (int i = 0; i < Sensor.values().length + 1; i++) { // actionBar.addTab(actionBar.newTab().setText("tab" + // i).setTabListener(tabListener)); // } // page swipe viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { Log.d(TAG, "onPageSelected position=" + position); actionBar.setSelectedNavigationItem(position); }; }); }
From source file:ru.orangesoftware.financisto.service.FinancistoService.java
private void scheduleOne(Intent intent) { long scheduledTransactionId = intent.getLongExtra(RecurrenceScheduler.SCHEDULED_TRANSACTION_ID, -1); if (scheduledTransactionId > 0) { TransactionInfo transaction = scheduler.scheduleOne(this, scheduledTransactionId); if (transaction != null) { notifyUser(transaction);/*w w w . j av a2s .c om*/ AccountWidget.updateWidgets(this); } } }
From source file:org.jnrain.mobile.ReadThreadActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dyn_pages);//from w w w . j a va 2s.c o m _adapter = new ReadThreadFragmentAdapter(getSupportFragmentManager(), getApplicationContext()); viewPager.setAdapter(_adapter); indicator.setViewPager(viewPager); indicator.setFooterIndicatorStyle(IndicatorStyle.Triangle); // Show the Up button in the action bar. getSupportActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); this._brd_id = intent.getStringExtra(BoardListActivity.BRD_ID); this._tid = intent.getLongExtra(ThreadListActivity.THREAD_ID, -1); this._title = intent.getStringExtra(ThreadListActivity.THREAD_TITLE); this._totalposts = intent.getIntExtra(BoardListActivity.NUM_POSTS, 1); // update title of action bar getSupportActionBar().setTitle(this._title); _totalpages = (int) Math.ceil((double) _totalposts / POSTS_PER_PAGE); // initial tabs addReplyPage(1); if (_totalpages == 1) { _page = 1; } else { _page = 2; addReplyPage(2); } // pager listener indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrollStateChanged(int state) { // intentionally left blank // Log.d(TAG, "PageScrollStateChanged: " + // Integer.toString(state)); } @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { // intentionally left blank } @Override public void onPageSelected(int position) { Log.d(TAG, "PageSelected: " + Integer.toString(position) + ", _page = " + Integer.toString(_page)); if (position == _page - 1) { // last tab, add another page if there are still // enough // threads to display if (_page < _totalpages) { _page++; addReplyPage(_page); } } } }); }
From source file:com.commonsware.android.job.PollReceiver.java
@Override public void onReceive(Context ctxt, Intent i) { boolean isDownload = i.getBooleanExtra(EXTRA_IS_DOWNLOAD, false); startWakefulService(ctxt,//ww w .ja va 2s . com new Intent(ctxt, DemoScheduledService.class).putExtra(EXTRA_IS_DOWNLOAD, isDownload)); long period = i.getLongExtra(EXTRA_PERIOD, -1); if (period > 0) { scheduleExactAlarm(ctxt, (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE), period, isDownload); } }
From source file:net.olejon.mdapp.SubstanceActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Intent//w w w . j av a 2s . c o m final Intent intent = getIntent(); final long substanceId = intent.getLongExtra("id", 0); // Open database SQLiteDatabase sqLiteDatabase = new SlDataSQLiteHelper(mContext).getReadableDatabase(); String[] queryColumns = { SlDataSQLiteHelper.SUBSTANCES_COLUMN_ATC_CODE, SlDataSQLiteHelper.SUBSTANCES_COLUMN_NAME }; Cursor cursor = sqLiteDatabase.query(SlDataSQLiteHelper.TABLE_SUBSTANCES, queryColumns, SlDataSQLiteHelper.SUBSTANCES_COLUMN_ID + " = " + substanceId, null, null, null, null); if (cursor.moveToFirst()) { // Substance substanceAtcCode = cursor .getString(cursor.getColumnIndexOrThrow(SlDataSQLiteHelper.SUBSTANCES_COLUMN_ATC_CODE)); substanceName = cursor .getString(cursor.getColumnIndexOrThrow(SlDataSQLiteHelper.SUBSTANCES_COLUMN_NAME)); // Layout setContentView(R.layout.activity_substance); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.substance_toolbar); toolbar.setTitle(substanceName); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // ATC code TextView atcCodeTextView = (TextView) findViewById(R.id.substance_atc_code); atcCodeTextView.setText(substanceAtcCode); // List mListView = (ListView) findViewById(R.id.substance_list); } // Close database cursor.close(); sqLiteDatabase.close(); }
From source file:net.olejon.mdapp.ManufacturerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Intent/*from ww w . ja v a 2 s .c om*/ final Intent intent = getIntent(); final long manufacturerId = intent.getLongExtra("id", 0); // Layout setContentView(R.layout.activity_manufacturer); // Get manufacturer mSqLiteDatabase = new SlDataSQLiteHelper(mContext).getReadableDatabase(); String[] manufacturersQueryColumns = { SlDataSQLiteHelper.MANUFACTURERS_COLUMN_NAME }; mCursor = mSqLiteDatabase.query(SlDataSQLiteHelper.TABLE_MANUFACTURERS, manufacturersQueryColumns, SlDataSQLiteHelper.MANUFACTURERS_COLUMN_ID + " = " + manufacturerId, null, null, null, null); if (mCursor.moveToFirst()) { manufacturerName = mCursor .getString(mCursor.getColumnIndexOrThrow(SlDataSQLiteHelper.MANUFACTURERS_COLUMN_NAME)); String[] medicationsQueryColumns = { SlDataSQLiteHelper.MEDICATIONS_COLUMN_ID, SlDataSQLiteHelper.MEDICATIONS_COLUMN_NAME, SlDataSQLiteHelper.MEDICATIONS_COLUMN_SUBSTANCE }; mCursor = mSqLiteDatabase.query(SlDataSQLiteHelper.TABLE_MEDICATIONS, medicationsQueryColumns, SlDataSQLiteHelper.MEDICATIONS_COLUMN_MANUFACTURER + " = " + mTools.sqe(manufacturerName), null, null, null, SlDataSQLiteHelper.MEDICATIONS_COLUMN_NAME + " COLLATE NOCASE"); String[] fromColumns = { SlDataSQLiteHelper.MEDICATIONS_COLUMN_NAME, SlDataSQLiteHelper.MEDICATIONS_COLUMN_SUBSTANCE }; int[] toViews = { R.id.manufacturer_list_item_name, R.id.manufacturer_list_item_substance }; SimpleCursorAdapter simpleCursorAdapter = new SimpleCursorAdapter(mContext, R.layout.activity_manufacturer_list_item, mCursor, fromColumns, toViews, 0); // Toolbar final Toolbar toolbar = (Toolbar) findViewById(R.id.manufacturer_toolbar); toolbar.setTitle(manufacturerName); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Medications count int medicationsCount = mCursor.getCount(); String medications = (medicationsCount == 1) ? getString(R.string.manufacturer_medication) : getString(R.string.manufacturer_medications); TextView medicationsCountTextView = (TextView) findViewById(R.id.manufacturer_medications_count); medicationsCountTextView.setText(medicationsCount + " " + medications); // List ListView listView = (ListView) findViewById(R.id.manufacturer_list); listView.setAdapter(simpleCursorAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (mCursor.moveToPosition(i)) { long id = mCursor .getLong(mCursor.getColumnIndexOrThrow(SlDataSQLiteHelper.MEDICATIONS_COLUMN_ID)); Intent intent = new Intent(mContext, MedicationActivity.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mTools.getDefaultSharedPreferencesBoolean("MEDICATION_MULTIPLE_DOCUMENTS")) intent.setFlags( Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_NEW_DOCUMENT); } intent.putExtra("id", id); startActivity(intent); } } }); } }
From source file:com.finchuk.clock2.timers.TimerNotificationService.java
private long getActionId(Intent intent) { return intent.getLongExtra(EXTRA_ACTION_ID, -1); }
From source file:com.renard.ocr.help.OCRLanguageInstallService.java
@Override protected void onHandleIntent(Intent intent) { if (!intent.hasExtra(DownloadManager.EXTRA_DOWNLOAD_ID)) { return;/*from ww w .ja va 2s . c o m*/ } final long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); if (downloadId != 0) { DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); ParcelFileDescriptor file; try { file = dm.openDownloadedFile(downloadId); FileInputStream fin = new FileInputStream(file.getFileDescriptor()); BufferedInputStream in = new BufferedInputStream(fin); FileOutputStream out = openFileOutput("tess-lang.tmp", Context.MODE_PRIVATE); GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in); final byte[] buffer = new byte[2048 * 2]; int n = 0; while (-1 != (n = gzIn.read(buffer))) { out.write(buffer, 0, n); } out.close(); gzIn.close(); FileInputStream fileIn = openFileInput("tess-lang.tmp"); TarArchiveInputStream tarIn = new TarArchiveInputStream(fileIn); TarArchiveEntry entry = tarIn.getNextTarEntry(); while (entry != null && !(entry.getName().endsWith(".traineddata") && !entry.getName().endsWith("_old.traineddata"))) { entry = tarIn.getNextTarEntry(); } if (entry != null) { File tessDir = Util.getTrainingDataDir(this); final String langName = entry.getName().substring("tesseract-ocr/tessdata/".length()); File trainedData = new File(tessDir, langName); FileOutputStream fout = new FileOutputStream(trainedData); int len; while ((len = tarIn.read(buffer)) != -1) { fout.write(buffer, 0, len); } fout.close(); String lang = langName.substring(0, langName.length() - ".traineddata".length()); notifyReceivers(lang); } tarIn.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { String tessDir = Util.getTessDir(this); File targetFile = new File(tessDir, OCRLanguageActivity.DOWNLOADED_TRAINING_DATA); if (targetFile.exists()) { targetFile.delete(); } } } }
From source file:org.amahi.anywhere.util.Downloader.java
private boolean isDownloadCurrent(Intent intent) { return downloadId == intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); }
From source file:hu.naturlecso.naturshutd.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == EditActivity.EDIT_REQUEST_CODE) { if (resultCode == RESULT_OK) { Long id = data.getLongExtra(EditActivity.EDIT_RESULT_ID, INVALID_ID); EditActivity.ModelType modelType = (EditActivity.ModelType) data .getSerializableExtra(EditActivity.EXTRA_EDIT_MODEL_TYPE); switch (modelType) { case HOST: updateHost(id);// w w w.j a va 2 s .c o m break; case COMMAND: EditActivity.OperationType operationType = (EditActivity.OperationType) data .getSerializableExtra(EditActivity.EXTRA_EDIT_OPERATION_TYPE); doCommandOperation(operationType, id); break; default: throw new UnsupportedOperationException("Unknown ModelType."); } } } }