Example usage for android.content Intent getLongExtra

List of usage examples for android.content Intent getLongExtra

Introduction

In this page you can find the example usage for android.content Intent getLongExtra.

Prototype

public long getLongExtra(String name, long defaultValue) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:org.gnucash.android.ui.transactions.TransactionsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_transactions);

    final Intent intent = getIntent();
    mAccountId = intent.getLongExtra(TransactionsListFragment.SELECTED_ACCOUNT_ID, -1);

    setupActionBarNavigation();/*from www. ja  v  a 2 s .  c  om*/

    if (intent.getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) {
        long transactionId = intent.getLongExtra(NewTransactionFragment.SELECTED_TRANSACTION_ID, -1);
        if (transactionId <= 0) {
            createNewTransaction(mAccountId);
        } else {
            editTransaction(transactionId);
        }
    } else { //load the transactions list               
        FragmentManager fragmentManager = getSupportFragmentManager();
        TransactionsListFragment transactionsListFragment = (TransactionsListFragment) fragmentManager
                .findFragmentByTag(FRAGMENT_TRANSACTIONS_LIST);

        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        transactionsListFragment = new TransactionsListFragment();
        Bundle args = new Bundle();
        args.putLong(TransactionsListFragment.SELECTED_ACCOUNT_ID, mAccountId);
        transactionsListFragment.setArguments(args);
        Log.i(TAG, "Opening transactions for account id " + mAccountId);

        fragmentTransaction.replace(R.id.fragment_container, transactionsListFragment,
                FRAGMENT_TRANSACTIONS_LIST);

        fragmentTransaction.commit();
    }

    // done creating, activity now running
    mActivityRunning = true;
}

From source file:com.rdrive.updateapk.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btn_update = (Button) findViewById(R.id.button_update);
    btn_update.setEnabled(false);//from ww  w  . j  av a 2 s. c o m

    currentVersionValue = (TextView) findViewById(R.id.currentVersionValue);
    lastVersionValue = (TextView) findViewById(R.id.lastVersionValue);

    dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);

    new CheckUpdate() {
        @Override
        protected void onPostExecute(Boolean aBoolean) {
            currentVersionValue.setText(this.getCurrentVersion().toString());
            lastVersionValue.setText(this.getLastVersion().toString());
            if (!aBoolean) {
                btn_update.setEnabled(true);
            }
        }
    }.execute(getContext());

    btn_update.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT > 22) {
                if (ContextCompat.checkSelfPermission(getActivity(),
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(getActivity(),
                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE },
                            ASK_WRITE_EXTERNAL_STORAGE_FOR_UPDATE);
                    return;
                }
            }
            downloadLastVersion(getContext(), dm);
        }
    });

    BroadcastReceiver attachmentDownloadCompleteReceive = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) {
                long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0);
                DownloadManager.Query query = new DownloadManager.Query();
                query.setFilterById(downloadId);
                Cursor cursor = dm.query(query);
                if (cursor.moveToFirst()) {
                    int downloadStatus = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS));
                    String downloadLocalUri = cursor
                            .getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
                    if ((downloadStatus == DownloadManager.STATUS_SUCCESSFUL) && downloadLocalUri != null) {
                        openApk(getContext(), downloadLocalUri);
                    }
                }
                cursor.close();
            }
        }
    };

    registerReceiver(attachmentDownloadCompleteReceive,
            new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
}

From source file:net.sf.diningout.app.ui.RestaurantsActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    long id = intent.getLongExtra(EXTRA_DELETE_ID, 0L);
    if (id > 0) {
        new Undoer(this, getString(R.string.n_deleted, 1), Restaurants.CONTENT_URI, new long[] { id }, DELETED,
                ACTIVE);/*from w w  w  . ja v  a 2 s  . c  om*/
    }
}

From source file:it.gulch.linuxday.android.services.AlarmIntentService.java

private void addBookmark(Intent intent) {
    long delay = getDelay();
    long eventId = intent.getLongExtra(ExtraConstants.EXTRA_EVENT_ID, -1L);
    long startTime = intent.getLongExtra(ExtraConstants.EXTRA_EVENT_START_TIME, -1L);

    // Only schedule future events. If they start before the delay, the alarm will go off immediately
    if ((startTime == -1L) || (startTime < System.currentTimeMillis())) {
        return;//from w  ww  .  j  av  a2s .c  o  m
    }

    alarmManager.set(AlarmManager.RTC_WAKEUP, startTime - delay, getAlarmPendingIntent(eventId));
}

From source file:com.remdo.app.EditDeviceActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_edit_device);
    this.dh = new DatabaseHelper(this);
    Intent intent = getIntent();
    Long deviceId = intent.getLongExtra("DEVICE_ID", -1);

    mDeviceNameView = (EditText) findViewById(R.id.edit_devicename);
    mHostView = (EditText) findViewById(R.id.edit_host);
    mUserView = (EditText) findViewById(R.id.edit_user);
    mPasswordView = (EditText) findViewById(R.id.edit_password);
    Button save = (Button) findViewById(R.id.button_accept);
    save.setOnClickListener(this);

    if (deviceId == -1) {
        EditMode = false;/*from  www .ja  v  a  2 s .c  o  m*/
        save.setText(R.string.save);
    } else {
        currentDevice = dh.getDevicebyID(deviceId);

        mDeviceNameView.setText(currentDevice.name, TextView.BufferType.EDITABLE);
        mHostView.setText(currentDevice.url, TextView.BufferType.EDITABLE);
        mUserView.setText(currentDevice.usr, TextView.BufferType.EDITABLE);
        mPasswordView.setText(currentDevice.pwd, TextView.BufferType.EDITABLE);
        EditMode = true;
        save.setText(R.string.edit);
    }
    setsnniper();

}

From source file:org.isoron.uhabits.HabitBroadcastReceiver.java

private void createNotification(Context context, Intent intent) {
    Uri data = intent.getData();//from   w w  w  .  j av  a2s.  co m
    Habit habit = Habit.get(ContentUris.parseId(data));
    Long timestamp = intent.getLongExtra("timestamp", DateHelper.getStartOfToday());
    Long reminderTime = intent.getLongExtra("reminderTime", DateHelper.getStartOfToday());

    if (habit == null)
        return;
    if (habit.repetitions.hasImplicitRepToday())
        return;

    habit.highlight = 1;
    habit.save();

    if (!checkWeekday(intent, habit))
        return;

    // Check if reminder has been turned off after alarm was scheduled
    if (habit.reminderHour == null)
        return;

    Intent contentIntent = new Intent(context, MainActivity.class);
    contentIntent.setData(data);
    PendingIntent contentPendingIntent = PendingIntent.getActivity(context, 0, contentIntent, 0);

    PendingIntent dismissPendingIntent = buildDismissIntent(context);
    PendingIntent checkIntentPending = buildCheckIntent(context, habit, timestamp);
    PendingIntent snoozeIntentPending = buildSnoozeIntent(context, habit);

    Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

    NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender()
            .setBackground(BitmapFactory.decodeResource(context.getResources(), R.drawable.stripe));

    Notification notification = new NotificationCompat.Builder(context).setSmallIcon(R.drawable.ic_notification)
            .setContentTitle(habit.name).setContentText(habit.description)
            .setContentIntent(contentPendingIntent).setDeleteIntent(dismissPendingIntent)
            .addAction(R.drawable.ic_action_check, context.getString(R.string.check), checkIntentPending)
            .addAction(R.drawable.ic_action_snooze, context.getString(R.string.snooze), snoozeIntentPending)
            .setSound(soundUri).extend(wearableExtender).setWhen(reminderTime).setShowWhen(true).build();

    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Activity.NOTIFICATION_SERVICE);

    int notificationId = (int) (habit.getId() % Integer.MAX_VALUE);
    notificationManager.notify(notificationId, notification);
}

From source file:de.schildbach.wallet.ui.ChannelRequestActivity.java

private void handleIntent(Intent intent) {
    appSpecifiedMinValue = intent.getLongExtra("minValue", 0);
    userSpecifiedMaxValue = null;//from  w w  w  .  java 2s  .c om
    if (service == null)
        bindService(new Intent(ChannelRequestActivity.this, ChannelService.class), connection,
                Context.BIND_AUTO_CREATE);
    else
        initWithBinder();
}

From source file:com.goftagram.telegram.messenger.AutoMessageReplyReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;//from   w w  w .j  av  a 2  s.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().sendMessage(text.toString(), dialog_id, null, null, true, false);
    MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}

From source file:com.negaheno.android.WearReplyReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;/*w ww  . ja  v a  2  s  .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().sendMessage(text.toString(), dialog_id);
    MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
}

From source file:org.hermes.android.WearReplyReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
    if (remoteInput == null) {
        return;/*ww  w . ja  v  a2  s .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().sendMessage(text.toString(), dialog_id, null, null, true);
    MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, 0, true, false);
}