List of usage examples for android.content Intent getLongExtra
public long getLongExtra(String name, long defaultValue)
From source file:com.b44t.messenger.AutoMessageReplyReceiver.java
@Override public void onReceive(Context context, Intent intent) { ApplicationLoader.postInitApplication(); Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput == null) { return;//from w w w . ja v a 2s. c o m } 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); if (dialog_id == 0 || max_id == 0) { return; } SendMessagesHelper.getInstance().sendMessageText(text.toString(), dialog_id, null); MrMailbox.markseenChat((int) dialog_id); NotificationsController.getInstance().removeSeenMessages(); }
From source file:org.strongswan.android.ui.VpnProfileListFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ADD_REQUEST: case EDIT_REQUEST: if (resultCode != Activity.RESULT_OK) { return; }/*from www . j av a 2 s . c om*/ long id = data.getLongExtra(VpnProfileDataSource.KEY_ID, 0); VpnProfile profile = mDataSource.getVpnProfile(id); if (profile != null) { /* in case this was an edit, we remove it first */ mVpnProfiles.remove(profile); mVpnProfiles.add(profile); mListAdapter.notifyDataSetChanged(); } return; } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.freshdigitable.udonroad.MediaViewActivity.java
@Override protected void onStart() { super.onStart(); userActionSubscriber.open();/* ww w . j a va 2 s . c om*/ userFeedback.setToastOption(Gravity.CENTER, 0, 0); final Intent intent = getIntent(); final long statusId = intent.getLongExtra(CREATE_STATUS, -1); final TypedCache<Status> statusCache = userActionSubscriber.getCache(); final Status status = statusCache.find(statusId); if (status == null) { Toast.makeText(getApplicationContext(), "status is not found", Toast.LENGTH_SHORT).show(); return; } final Status bindingStatus = StatusViewImageHelper.getBindingStatus(status); final int startPage = intent.getIntExtra(CREATE_START, 0); binding.mediaPager.setAdapter( new MediaPagerAdapter(getSupportFragmentManager(), bindingStatus.getExtendedMediaEntities())); binding.mediaPager.addOnPageChangeListener(pageChangeListener); binding.mediaPager.setCurrentItem(startPage); setTitle(); setupActionMap(statusId); UserAction.setupFlingableFAB(binding.mediaIffab, actionMap, getApplicationContext()); }
From source file:com.mobvoi.knowledgegraph.wearcontroltetris.activities.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode != SCORE_REQUEST) return;//from www.ja v a 2 s. com if (resultCode != RESULT_OK) return; String playerName = data.getStringExtra(PLAYERNAME_KEY); long score = data.getLongExtra(SCORE_KEY, 0); datasource.open(); datasource.createScore(score, playerName); }
From source file:com.tenmiles.helpstack.service.AttachmentDownloadReceiver.java
private void downloadCompleted(Context context, Intent intent) { StringBuilder text = new StringBuilder(); //Files are ready String filename = context.getString(R.string.hs_attachment); String filepath = null;// w w w . jav a 2 s.c om String mediaType = null; DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); Query query = new Query(); query.setFilterById(downloadId); Cursor c = dm.query(query); if (c.moveToFirst()) { int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)); filename = c.getString(c.getColumnIndex(DownloadManager.COLUMN_TITLE)); filepath = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); mediaType = c.getString(c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE)); if (status == DownloadManager.STATUS_SUCCESSFUL) { text.append(context.getString(R.string.hs_download_complete)); } else { text.append(context.getString(R.string.hs_error_during_download)); } } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(context); notificationbuilder.setAutoCancel(true); notificationbuilder.setContentText(text.toString()); notificationbuilder.setContentTitle(filename); notificationbuilder.setSmallIcon(R.drawable.hs_notification_download_img); notificationbuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); notificationbuilder.setContentIntent(getPendingIntent(context)); notificationManager.notify(filename, NOTIFICATION_ID, notificationbuilder.build()); }
From source file:eu.inmite.apps.smsjizdenka.activity.MainActivity.java
private void handleIntent(Intent intent) { //React to notification when you really want to buy another ticket in a short time. if (intent.hasExtra(EXTRA_REALLY_BUY_CITY_ID)) { long cityId = intent.getLongExtra(EXTRA_REALLY_BUY_CITY_ID, -1); // delete extras so no intent can be catched again intent.removeExtra(EXTRA_REALLY_BUY_CITY_ID); getIntent().removeExtra(EXTRA_REALLY_BUY_CITY_ID); BuyTicketConfirmationDialogFragment.newInstance(cityId).show(getSupportFragmentManager(), BuyTicketConfirmationDialogFragment.TAG); }/*from w ww.ja v a2 s. c om*/ // pubtran integration if (intent.hasExtra(EXTRA_AREA)) { City city = CityManager.get(c).getCityByPubtranCity(c, intent.getStringExtra(EXTRA_AREA)); if (city != null) { int minutes = intent.getIntExtra(EXTRA_MINUTES, 0); //SL.get(AnalyticsService.class).trackEvent("pubtran", "on-start", "city", city.city, "minutes", String.valueOf(minutes)); Intent i = new Intent(c, CityTicketsActivity.class); i.putExtra(CityTicketsActivity.EXTRA_CITY, city.city); i.putExtra(CityTicketsActivity.EXTRA_MINUTES, intent.getIntExtra(EXTRA_MINUTES, 0)); startActivity(i); } } // message from inmite if (intent.hasExtra(EXTRA_MESSAGE) && !Preferences.getBoolean(c, Preferences.MESSAGE_READ, false)) { MessageDialogFragment.newInstance(intent.getStringExtra(EXTRA_MESSAGE)) .show(getSupportFragmentManager(), MessageDialogFragment.TAG); Preferences.set(c, Preferences.MESSAGE_READ, true); } }
From source file:ru.appsm.inapphelp.service.AttachmentDownloadReceiver.java
private void downloadCompleted(Context context, Intent intent) { StringBuilder text = new StringBuilder(); //Files are ready String filename = context.getString(R.string.iah_attachment); String filepath = null;/*from w w w . java 2 s . c o m*/ String mediaType = null; DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); Query query = new Query(); query.setFilterById(downloadId); Cursor c = dm.query(query); if (c.moveToFirst()) { int status = c.getInt(c.getColumnIndex(DownloadManager.COLUMN_STATUS)); filename = c.getString(c.getColumnIndex(DownloadManager.COLUMN_TITLE)); filepath = c.getString(c.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI)); mediaType = c.getString(c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE)); if (status == DownloadManager.STATUS_SUCCESSFUL) { text.append(context.getString(R.string.iah_download_complete)); } else { text.append(context.getString(R.string.iah_error_during_download)); } } NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder notificationbuilder = new NotificationCompat.Builder(context); notificationbuilder.setAutoCancel(true); notificationbuilder.setContentText(text.toString()); notificationbuilder.setContentTitle(filename); notificationbuilder.setSmallIcon(R.drawable.iah_notification_download_light_img); notificationbuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE); notificationbuilder.setContentIntent(getPendingIntent(context)); notificationManager.notify(filename, NOTIFICATION_ID, notificationbuilder.build()); }
From source file:com.commonsware.android.arXiv.ArticleListFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); sortBy = prefs.getString("sortBy", "lastUpdatedDate"); fontSize = prefs.getInt("fontSize", 16); footer = getActivity().getLayoutInflater().inflate(R.layout.activity_circle, null); errorStrip = getActivity().getLayoutInflater().inflate(R.layout.error_strip, null); View icon = errorStrip.findViewById(R.id.refresh); icon.setOnClickListener(new View.OnClickListener() { @Override/* ww w .j av a 2s .c om*/ public void onClick(View view) { getListView().addFooterView(footer); getListView().removeFooterView(errorStrip); loaderManager.restartLoader(0, ArticleListFragment.this); } }); errorMsg = (TextView) errorStrip.findViewById(R.id.errorMsg); getListView().addFooterView(footer); getListView().setOnScrollListener(this); Intent intent = getActivity().getIntent(); name = intent.getStringExtra("keyname"); query = intent.getStringExtra("keyquery"); url = intent.getStringExtra("keyurl"); feedId = intent.getLongExtra("feedId", -1); loaderManager = new arXivLoader.arXivLoaderManager(getLoaderManager()); Object o = getActivity().getLastCustomNonConfigurationInstance(); if (o != null && o instanceof ArticleList.Item[]) { adapter = new ArticleAdapter((ArticleList.Item[]) o); setListAdapter(adapter); getListView().removeFooterView(footer); firstResult = adapter.getCount() + 1; totalCount = savedInstanceState.getInt("totalCount"); error = savedInstanceState.getBoolean("error"); if (error) { errorMsg.setText(savedInstanceState.getCharSequence("errorMsg")); getListView().addFooterView(errorStrip); } } else { adapter = new ArticleAdapter(); loaderManager.initLoader(0, this); } }
From source file:com.google.android.apps.iosched.calendar.SessionAlarmService.java
@Override protected void onHandleIntent(Intent intent) { final String action = intent.getAction(); if (ACTION_SCHEDULE_ALL_STARRED_BLOCKS.equals(action)) { scheduleAllStarredBlocks();/*from w w w.j a v a2 s .c o m*/ return; } final long sessionStart = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_START, -1); if (sessionStart == -1) { return; } final long sessionEnd = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_END, -1); if (sessionEnd == -1) { return; } final long sessionAlarmOffset = intent.getLongExtra(SessionAlarmService.EXTRA_SESSION_ALARM_OFFSET, UNDEFINED_ALARM_OFFSET); if (ACTION_NOTIFY_SESSION.equals(action)) { notifySession(sessionStart, sessionEnd, sessionAlarmOffset); } else if (ACTION_SCHEDULE_STARRED_BLOCK.equals(action)) { scheduleAlarm(sessionStart, sessionEnd, sessionAlarmOffset); } }
From source file:com.flowzr.activity.LocationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.location);//from www . j a v a2s . co m setUpMapIfNeeded(); db = new DatabaseAdapter(this); db.open(); em = db.em(); txtViewLocation = (TextView) findViewById(R.id.location); // These settings are the same as the settings for the map. They will in fact give you updates at // the maximal rates currently possible. mLocationRequest = LocationRequest.create().setInterval(5000) // 5 seconds .setFastestInterval(16) // 16ms = 60fps .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); /* * Create a new location client, using the enclosing class to * handle callbacks. */ mLocationClient = new LocationClient(this, this, this); //setup basic androids widgets Intent intent = getIntent(); if (intent != null) { long locationId = intent.getLongExtra(LOCATION_ID_EXTRA, -1); if (locationId != -1) { orbLocation = em.load(MyLocation.class, locationId); EditText name = (EditText) findViewById(R.id.name); name.setText(orbLocation.name); if (orbLocation.resolvedAddress != null) { txtViewLocation.setText(orbLocation.resolvedAddress); } } } Button bOK = (Button) findViewById(R.id.okButton); bOK.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (orbLocation != null && mMarker != null) { EditText name = (EditText) findViewById(R.id.name); orbLocation.latitude = mMarker.getPosition().latitude; orbLocation.longitude = mMarker.getPosition().longitude; if (Utils.checkEditText(name, "name", true, 100)) { new SolveSaveLocationTask(getApplicationContext(), true).execute(orbLocation); } } } }); }