Java Code Examples for android.content.Intent#getLongExtra()
The following examples show how to use
android.content.Intent#getLongExtra() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AccountingEditPresenter.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@Override public void updateAccounting(Intent intent, int resultCode) { if (intent != null) { switch (resultCode) { case DatePickerActivity.FOR_DATE_RESULT: time = intent.getLongExtra(DatePickerActivity.DATE, System.currentTimeMillis()); mAccountingEditView.setDateText(sf.format(new Date(time))); break; case ItemExpenseActivity.FOR_SELECT_ITEM: tempProject = intent.getStringExtra(ItemExpenseActivity.ITEM); mAccountingEditView.setProject(tempProject); break; case ItemIncomeActivity.FOR_SELECT_ITEM: tempProject = intent.getStringExtra(ItemIncomeActivity.ITEM); mAccountingEditView.setProject(tempProject); break; } } }
Example 2
Source File: MemoryTracker.java From Trebuchet with GNU General Public License v3.0 | 6 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.v(TAG, "Received start id " + startId + ": " + intent); if (intent != null) { if (ACTION_START_TRACKING.equals(intent.getAction())) { final int pid = intent.getIntExtra("pid", -1); final String name = intent.getStringExtra("name"); final long start = intent.getLongExtra("start", System.currentTimeMillis()); startTrackingProcess(pid, name, start); } } mHandler.sendEmptyMessage(MSG_START); return START_STICKY; }
Example 3
Source File: WBAlbumActivity.java From Simpler with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wb_album); ButterKnife.bind(this); Intent intent = getIntent(); mUid = intent.getLongExtra(INTENT_UID, 0L); String name = intent.getStringExtra(INTENT_NAME); mTvTitle.setText(getString(R.string.title_album, name)); mAdapter = new AlbumsAdapter(this); mSwipeRefresh.setRecyclerViewAndAdapter(mRvPhotos, mAdapter, 3); mSwipeRefresh.setOnRefreshListener(mRefreshListener); mSwipeRefresh.setOnLoadingListener(mLoadingListener); queryPhotos(0, true); mSwipeRefresh.setRefreshing(true); }
Example 4
Source File: MrdtSupport.java From medic-android with GNU Affero General Public License v3.0 | 6 votes |
String process(int requestCode, int resultCode, Intent i) { trace(this, "process() :: requestCode=%s", requestCode); switch(requestCode) { case GRAB_MRDT_PHOTO: { try { byte[] data = i.getByteArrayExtra("data"); String base64data = Base64.encodeToString(data, Base64.NO_WRAP); long timeTaken = i.getLongExtra("timeTaken", 0); String javaScript = "var api = angular.element(document.body).injector().get('AndroidApi');" + "if (api.v1.mrdtTimeTakenResponse) {" + " api.v1.mrdtTimeTakenResponse('\"%s\"');" + "}" + "api.v1.mrdtResponse('\"%s\"');"; return safeFormat(javaScript, String.valueOf(timeTaken), base64data); } catch(Exception /*| JSONException*/ ex) { warn(ex, "Problem serialising mrdt image."); return safeFormat("console.log('Problem serialising mrdt image: %s')", ex); } } default: throw new RuntimeException("Bad request type: " + requestCode); } }
Example 5
Source File: ClockActivity.java From ToDoList with Apache License 2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(ClockService.ACTION_COUNTDOWN_TIMER)) { String requestAction = intent.getStringExtra(ClockService.REQUEST_ACTION); switch (requestAction) { case ClockService.ACTION_TICK: long millisUntilFinished = intent.getLongExtra( ClockService.MILLIS_UNTIL_FINISHED, 0); mProgressBar.setProgress(millisUntilFinished / 1000); updateText(millisUntilFinished); break; case ClockService.ACTION_FINISH: case ClockService.ACTION_AUTO_START: reload(); break; } } }
Example 6
Source File: AutoMessageReplyReceiver.java From Telegram with GNU General Public License v2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { ApplicationLoader.postInitApplication(); Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) { return; } CharSequence text = remoteInput.getCharSequence(NotificationsController.EXTRA_VOICE_REPLY); if (text == null || text.length() == 0) { return; } long dialog_id = intent.getLongExtra("dialog_id", 0); int max_id = intent.getIntExtra("max_id", 0); int currentAccount = intent.getIntExtra("currentAccount", 0); if (dialog_id == 0 || max_id == 0) { return; } SendMessagesHelper.getInstance(currentAccount).sendMessage(text.toString(), dialog_id, null, null, true, null, null, null, true, 0); MessagesController.getInstance(currentAccount).markDialogAsRead(dialog_id, max_id, max_id, 0, false, 0, true, 0); }
Example 7
Source File: AutoMessageHeardReceiver.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onReceive(Context context, Intent intent) { ApplicationLoader.postInitApplication(); long dialog_id = intent.getLongExtra("dialog_id", 0); int max_id = intent.getIntExtra("max_id", 0); int currentAccount = intent.getIntExtra("currentAccount", 0); if (dialog_id == 0 || max_id == 0) { return; } int lowerId = (int) dialog_id; int highId = (int) (dialog_id >> 32); AccountInstance accountInstance = AccountInstance.getInstance(currentAccount); if (lowerId > 0) { TLRPC.User user = accountInstance.getMessagesController().getUser(lowerId); if (user == null) { Utilities.globalQueue.postRunnable(() -> { TLRPC.User user1 = accountInstance.getMessagesStorage().getUserSync(lowerId); AndroidUtilities.runOnUIThread(() -> { accountInstance.getMessagesController().putUser(user1, true); MessagesController.getInstance(currentAccount).markDialogAsRead(dialog_id, max_id, max_id, 0, false, 0, true, 0); }); }); return; } } else if (lowerId < 0) { TLRPC.Chat chat = accountInstance.getMessagesController().getChat(-lowerId); if (chat == null) { Utilities.globalQueue.postRunnable(() -> { TLRPC.Chat chat1 = accountInstance.getMessagesStorage().getChatSync(-lowerId); AndroidUtilities.runOnUIThread(() -> { accountInstance.getMessagesController().putChat(chat1, true); MessagesController.getInstance(currentAccount).markDialogAsRead(dialog_id, max_id, max_id, 0, false, 0, true, 0); }); }); return; } } MessagesController.getInstance(currentAccount).markDialogAsRead(dialog_id, max_id, max_id, 0, false, 0, true, 0); }
Example 8
Source File: NotUsedMobileCellsDetectedActivity.java From PhoneProfilesPlus with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); overridePendingTransition(0, 0); //PPApplication.logE("NotUsedMobileCellsDetectedActivity.onCreate", "xxx"); Intent intent = getIntent(); if (intent != null) { mobileCellId = intent.getIntExtra(EXTRA_MOBILE_CELL_ID, 0); lastConnectedTime = intent.getLongExtra(EXTRA_MOBILE_LAST_CONNECTED_TIME, 0); lastRunningEvents = intent.getStringExtra(EXTRA_MOBILE_LAST_RUNNING_EVENTS); lastPausedEvents = intent.getStringExtra(EXTRA_MOBILE_LAST_PAUSED_EVENTS); } }
Example 9
Source File: MainActivity.java From VinylMusicPlayer with GNU General Public License v3.0 | 5 votes |
private long parseIdFromIntent(@NonNull Intent intent, String longKey, String stringKey) { long id = intent.getLongExtra(longKey, -1); if (id < 0) { String idString = intent.getStringExtra(stringKey); if (idString != null) { try { id = Long.parseLong(idString); } catch (NumberFormatException e) { Log.e(TAG, e.getMessage()); } } } return id; }
Example 10
Source File: MainActivity.java From spidey with GNU General Public License v3.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if (savedInstanceState == null) { mMapFragment = new MapFragment(); getFragmentManager().beginTransaction() .add(R.id.container, mMapFragment).commit(); } //setupTabs(); Intent i = getIntent(); if (i.hasExtra("scan_id")) { final long scan_id = i.getLongExtra("scan_id", -1); final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { // Do something after 5s = 5000ms showScanMap(scan_id); } }, 2000); } else showWelcome(); }
Example 11
Source File: MainActivity.java From arcgis-runtime-demos-android with Apache License 2.0 | 5 votes |
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Receive results from either map or list geofence selection - both give // exactly the same information. if (data == null) return; if (resultCode == RESULT_OK) { long fenceOid = data.getLongExtra(GEOFENCE_FEATURE_OBJECTID_EXTRA_ID, -1); Feature fenceFeature = getFeatureFromGeodatabase(fenceOid); if (fenceFeature != null) { Polygon fencePolygon = (Polygon) fenceFeature.getGeometry(); final String fenceName = fenceFeature.getAttributeValue(FENCE_NAME_FIELD).toString(); LocalGeofence.setFence(fencePolygon, mGdbFeatureTable.getSpatialReference()); LocalGeofence.setFeatureName(fenceName); LocalGeofence.setFeatureOid(fenceOid); final GeofenceAlertItem geofenceAlertItem = new GeofenceAlertItem(alertString, fenceName, String.valueOf(fenceOid), geofenceAlertThumbnail, false); mGeofenceListViewerAdapter.add(geofenceAlertItem); final Snackbar snackbar = Snackbar .make(coordinatorLayout, "Added Geofence County: " + fenceName, Snackbar.LENGTH_LONG); snackbar.setAction("UNDO", new View.OnClickListener() { @Override public void onClick(View v) { mGeofenceListViewerAdapter.remove(geofenceAlertItem); Snackbar snackbarRemove = Snackbar .make(coordinatorLayout, "Removed Geofence County: " + fenceName, Snackbar.LENGTH_LONG); snackbarRemove.show(); } }); snackbar.show(); } } }
Example 12
Source File: MainLaunchUtils.java From letv with Apache License 2.0 | 5 votes |
public static void launchDemand(Activity activity, Intent intent) { long aid = intent.getLongExtra("aid", 0); long vid = intent.getLongExtra("vid", 0); boolean isFromPush = intent.getBooleanExtra(MyDownloadActivityConfig.FROM_PUSH, false); if (aid > 0 || vid > 0) { LeMessageManager.getInstance().dispatchMessage(new LeMessage(1, new AlbumPlayActivityConfig(activity).create(aid, vid, isFromPush ? 13 : 2))); } }
Example 13
Source File: IntentService.java From NightWatch with GNU General Public License v3.0 | 5 votes |
@Override protected void onHandleIntent(Intent intent) { if (intent == null) return; final String action = intent.getAction(); try { if (ACTION_NEW_DATA.equals(action)) { final double bgEstimate = intent.getDoubleExtra(Intents.EXTRA_BG_ESTIMATE, 0); if (bgEstimate == 0) return; int battery = intent.getIntExtra(Intents.EXTRA_SENSOR_BATTERY, 0); final Bg bg = new Bg(); bg.direction = intent.getStringExtra(Intents.EXTRA_BG_SLOPE_NAME); bg.battery = Integer.toString(battery); bg.bgdelta = (intent.getDoubleExtra(Intents.EXTRA_BG_SLOPE, 0) * 1000 * 60 * 5); bg.datetime = intent.getLongExtra(Intents.EXTRA_TIMESTAMP, new Date().getTime()); //bg.sgv = Integer.toString((int) bgEstimate, 10); bg.sgv = Math.round(bgEstimate)+""; bg.raw = intent.getDoubleExtra(Intents.EXTRA_RAW, 0); bg.save(); DataCollectionService.newDataArrived(this, true, bg); } } finally { WakefulBroadcastReceiver.completeWakefulIntent(intent); } }
Example 14
Source File: SmsIntentService.java From RememBirthday with GNU General Public License v3.0 | 5 votes |
@Override protected void onHandleIntent(Intent intent) { Log.i(getClass().getName(), "Handling intent"); timestampCreated = intent.getLongExtra(AutoSmsDbHelper.COLUMN_TIMESTAMP_CREATED, 0L); if (timestampCreated == 0) { Log.i(getClass().getName(), "Cannot identify sms: no creation timestamp provided"); } }
Example 15
Source File: ActivityView.java From FairEmail with GNU General Public License v3.0 | 4 votes |
private void onViewFolders(Intent intent) { long account = intent.getLongExtra("id", -1); onMenuFolders(account); }
Example 16
Source File: PbChatLocalSearchActivity.java From imsdk-android with MIT License | 4 votes |
@Override protected void injectExtras(Intent intent) { super.injectExtras(intent); startTime = intent.getLongExtra(KEY_START_TIME,0); }
Example 17
Source File: MainActivity.java From OneTapVideoDownload with GNU General Public License v3.0 | 4 votes |
private void handleActionDownloadDialog(Intent intent) { long videoId = intent.getLongExtra("videoId", -1); if (videoId != -1) { showVideoDownloadDialog(videoId); } }
Example 18
Source File: CameraActivity.java From smart-farmer-android with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_camera); Intent intent = getIntent(); savePath = intent.getStringExtra(ARG_SAVE_PATH); durationLimit = intent.getLongExtra(ARG_MAX_DURATION, 10000); minDuration = intent.getLongExtra(ARG_MIN_DURATION, 2000); // textTime = findViewById(R.id.text_time); jCameraView = findViewById(R.id.jcameraview); captureLayout = findViewById(R.id.capture_layout); //四舍五入 captureLayout.setDuration((int) (durationLimit + 500)); CaptureButton captureButton = findCaptureButton(captureLayout); if (captureButton != null) { captureButton.setMinDuration((int) minDuration); } //设置视频保存路径 jCameraView.setSaveVideoPath(savePath + "video"); jCameraView.setMediaQuality(JCameraView.MEDIA_QUALITY_MIDDLE); //JCameraView监听 jCameraView.setJCameraLisenter(new JCameraListener() { @Override public void captureSuccess(final Bitmap bitmap) { releaseBitmap(captureBmp); captureBmp = bitmap; if (isFinishing()) { return; } final ProgressDialog dialog = showProgressDialog(); Observable.create(new ObservableOnSubscribe<String>() { @Override public void subscribe(ObservableEmitter<String> e) throws Exception { File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "picture-" + dateFormat.format(new Date()) + ".jpg"); ImageUtils.save(bitmap, file, Bitmap.CompressFormat.JPEG, true); e.onNext(file.getAbsolutePath()); e.onComplete(); } }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer<String>() { @Override public void accept(String s) throws Exception { dialog.dismiss(); if (TextUtils.isEmpty(s)) { Toast.makeText(CameraActivity.this, "拍照失败", Toast.LENGTH_SHORT).show(); } else { handleResult(s, false); } } }); } @Override public void recordSuccess(String url, Bitmap firstFrame) { releaseBitmap(firstBmp); firstBmp = firstFrame; handleResult(url, true); } }); jCameraView.setLeftClickListener(new ClickListener() { @Override public void onClick() { CameraActivity.this.finish(); } }); }
Example 19
Source File: SplashActivity.java From pokemon-go-xposed-mitm with GNU General Public License v3.0 | 4 votes |
private void registerPackageInstallReceiver() { receiver = new BroadcastReceiver(){ public void onReceive(Context context, Intent intent) { Log.d("Received intent: " + intent + " (" + intent.getExtras() + ")"); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) { long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); if (downloadId == enqueue) { if (localFile.exists()) { return; } Query query = new Query(); query.setFilterById(enqueue); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); Cursor c = dm.query(query); if (c.moveToFirst()) { hideProgress(); int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)); if (DownloadManager.STATUS_SUCCESSFUL == status) { storeDownload(dm, downloadId); installDownload(); } else { int reason = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_REASON)); Toast.makeText(context,"Download failed (" + status + "): " + reason, Toast.LENGTH_LONG).show(); } } else { Toast.makeText(context,"Download diappeared!", Toast.LENGTH_LONG).show(); } c.close(); } } else if (Intent.ACTION_PACKAGE_ADDED.equals(intent.getAction())) { if (intent.getData().toString().equals("package:org.ruboto.core")) { Toast.makeText(context,"Ruboto Core is now installed.",Toast.LENGTH_LONG).show(); deleteFile(RUBOTO_APK); if (receiver != null) { unregisterReceiver(receiver); receiver = null; } initJRuby(false); } else { Toast.makeText(context,"Installed: " + intent.getData().toString(),Toast.LENGTH_LONG).show(); } } } }; IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_ADDED); filter.addDataScheme("package"); registerReceiver(receiver, filter); IntentFilter download_filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE); registerReceiver(receiver, download_filter); }
Example 20
Source File: SampleMediaRouteProvider.java From V.FlyoutTest with MIT License | 4 votes |
private boolean handleEnqueue(Intent intent, ControlRequestCallback callback) { String sid = intent.getStringExtra(MediaControlIntent.EXTRA_SESSION_ID); if (sid != null && !sid.equals(mSessionManager.getSessionId())) { Log.d(TAG, "handleEnqueue fails because of bad sid="+sid); return false; } Uri uri = intent.getData(); if (uri == null) { Log.d(TAG, "handleEnqueue fails because of bad uri="+uri); return false; } boolean enqueue = intent.getAction().equals(MediaControlIntent.ACTION_ENQUEUE); String mime = intent.getType(); long pos = intent.getLongExtra(MediaControlIntent.EXTRA_ITEM_CONTENT_POSITION, 0); Bundle metadata = intent.getBundleExtra(MediaControlIntent.EXTRA_ITEM_METADATA); Bundle headers = intent.getBundleExtra(MediaControlIntent.EXTRA_ITEM_HTTP_HEADERS); PendingIntent receiver = (PendingIntent)intent.getParcelableExtra( MediaControlIntent.EXTRA_ITEM_STATUS_UPDATE_RECEIVER); Log.d(TAG, mRouteId + ": Received " + (enqueue?"enqueue":"play") + " request" + ", uri=" + uri + ", mime=" + mime + ", sid=" + sid + ", pos=" + pos + ", metadata=" + metadata + ", headers=" + headers + ", receiver=" + receiver); PlaylistItem item = mSessionManager.add(uri, mime, receiver); if (callback != null) { if (item != null) { Bundle result = new Bundle(); result.putString(MediaControlIntent.EXTRA_SESSION_ID, item.getSessionId()); result.putString(MediaControlIntent.EXTRA_ITEM_ID, item.getItemId()); result.putBundle(MediaControlIntent.EXTRA_ITEM_STATUS, item.getStatus().asBundle()); callback.onResult(result); } else { callback.onError("Failed to open " + uri.toString(), null); } } mEnqueueCount +=1; return true; }