Example usage for android.content Intent getLongArrayExtra

List of usage examples for android.content Intent getLongArrayExtra

Introduction

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

Prototype

public long[] getLongArrayExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:Main.java

public static long[] getLongArrayExtra(Intent intent, String name) {
    if (!hasIntent(intent) || !hasExtra(intent, name))
        return null;
    return intent.getLongArrayExtra(name);
}

From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.AppObj.java

public static DbObject fromPickerResult(Context context, String action, ResolveInfo resolveInfo,
        Intent pickerResult) {
    long[] contactIds = pickerResult.getLongArrayExtra("contacts");
    String pkgName = resolveInfo.activityInfo.packageName;
    String className = resolveInfo.activityInfo.name;

    /**//from   ww w.  ja  va2  s .  c  o  m
     * TODO:
     * 
     * Identity Firewall Goes Here.
     * Membership details can be randomized in one of many ways.
     * The app (scrabble) may see games a set of gamers play together.
     * The app may always see random ids
     * The app may always see stable ids
     * 
     * Can also permute the cursor and member order.
     */

    JSONArray participantIds = new JSONArray();

    participantIds.put(App.instance().getLocalPersonId());
    for (long id : contactIds) {
        Maybe<Contact> annoyingContact = Contact.forId(context, id);
        try {
            Contact contact = annoyingContact.get();
            participantIds.put(contact.personId);
        } catch (NoValError e) {
            participantIds.put(Contact.UNKNOWN);
        }
    }
    JSONObject json = new JSONObject();
    try {
        json.put(Multiplayer.OBJ_MEMBERSHIP, (participantIds));
        json.put(ANDROID_ACTION, action);
        json.put(ANDROID_PACKAGE_NAME, pkgName);
        json.put(ANDROID_CLASS_NAME, className);
    } catch (JSONException e) {
        Log.d(TAG, "What? Impossible!", e);
    }
    return new DbObject(TYPE, json);
}

From source file:com.irccloud.android.NotificationDismissBroadcastReceiver.java

@Override
public void onReceive(Context ctx, Intent i) {
    if (i.hasExtra("eids")) {
        int bid = i.getIntExtra("bid", -1);
        long[] eids = i.getLongArrayExtra("eids");
        for (int j = 0; j < eids.length; j++) {
            if (eids[j] > 0) {
                Crashlytics.log(Log.INFO, "IRCCloud", "Dismiss bid" + bid + " eid" + eids[j]);
                NotificationsList.getInstance().dismiss(bid, eids[j]);
                NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext())
                        .cancel((int) (eids[j] / 1000));
            }//from  w  ww.  j  a va2s. co m
        }
        Crashlytics.log(Log.INFO, "IRCCloud", "Cancel bid" + bid);
        NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext()).cancel(bid);
    }
    IRCCloudApplication.getInstance().getApplicationContext()
            .sendBroadcast(new Intent(DashClock.REFRESH_INTENT));
}

From source file:org.sufficientlysecure.keychain.remote.ui.RemoteBackupActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // noinspection ConstantConditions, we know this activity has an action bar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (savedInstanceState == null) {
        Intent intent = getIntent();
        boolean exportSecret = intent.getBooleanExtra(EXTRA_SECRET, false);
        long[] masterKeyIds = intent.getLongArrayExtra(EXTRA_MASTER_KEY_IDS);
        mPendingIntentData = getIntent().getParcelableExtra(EXTRA_DATA);

        // NOTE: return backup!
        Fragment frag = BackupCodeFragment.newInstance(masterKeyIds, exportSecret, false);

        FragmentManager fragMan = getSupportFragmentManager();
        fragMan.beginTransaction().setCustomAnimations(0, 0).replace(R.id.content_frame, frag).commit();
    }/*from  w  ww  .j a  va2s  . co  m*/

}

From source file:org.sufficientlysecure.keychain.ui.BackupActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // noinspection ConstantConditions, we know this activity has an action bar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    if (savedInstanceState == null) {
        Intent intent = getIntent();
        boolean exportSecret = intent.getBooleanExtra(EXTRA_SECRET, false);
        long[] masterKeyIds = intent.getLongArrayExtra(EXTRA_MASTER_KEY_IDS);

        Fragment frag = BackupCodeFragment.newInstance(masterKeyIds, exportSecret, true);

        FragmentManager fragMan = getSupportFragmentManager();
        fragMan.beginTransaction().setCustomAnimations(0, 0).replace(R.id.content_frame, frag).commit();
    }/*from  w  ww  .  ja  v  a 2s  . c o  m*/

}

From source file:de.vanita5.twittnuker.activity.support.AccountSelectorActivity.java

private long[] getIntentExtraIds() {
    final Intent intent = getIntent();
    return intent.getLongArrayExtra(EXTRA_IDS);
}

From source file:org.thoughtcrime.securesms.notifications.AndroidAutoHeardReceiver.java

@Override
protected void onReceive(final Context context, Intent intent, @Nullable final MasterSecret masterSecret) {
    if (!HEARD_ACTION.equals(intent.getAction()))
        return;//  ww  w.ja  v a  2s.  c om

    final long[] threadIds = intent.getLongArrayExtra(THREAD_IDS_EXTRA);

    if (threadIds != null) {
        int notificationId = intent.getIntExtra(NOTIFICATION_ID_EXTRA, -1);
        NotificationManagerCompat.from(context).cancel(notificationId);

        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                List<MarkedMessageInfo> messageIdsCollection = new LinkedList<>();

                for (long threadId : threadIds) {
                    Log.i(TAG, "Marking meassage as read: " + threadId);
                    List<MarkedMessageInfo> messageIds = DatabaseFactory.getThreadDatabase(context)
                            .setRead(threadId, true);

                    messageIdsCollection.addAll(messageIds);
                }

                MessageNotifier.updateNotification(context, masterSecret);
                MarkReadReceiver.process(context, messageIdsCollection);

                return null;
            }
        }.execute();
    }
}

From source file:org.sufficientlysecure.keychain.remote.ui.RequestKeyPermissionActivity.java

@Override
protected void onStart() {
    super.onStart();

    Intent intent = getIntent();
    String packageName = intent.getStringExtra(EXTRA_PACKAGE_NAME);
    long masterKeyIds[] = intent.getLongArrayExtra(EXTRA_REQUESTED_KEY_IDS);

    presenter.setupFromIntentData(packageName, masterKeyIds);
}

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

private void removeBookmarks(Intent intent) {
    // Cancel matching alarms, might they exist or not
    long[] eventIds = intent.getLongArrayExtra(ExtraConstants.EXTRA_EVENT_IDS);
    for (long eventId : eventIds) {
        alarmManager.cancel(getAlarmPendingIntent(eventId));
    }//w  ww .j av  a  2  s. co  m
}

From source file:com.tingtingapps.securesms.notifications.WearReplyReceiver.java

@Override
protected void onReceive(final Context context, Intent intent, final @Nullable MasterSecret masterSecret) {
    if (!REPLY_ACTION.equals(intent.getAction()))
        return;//  w w  w .  j  ava  2  s . c om

    Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);

    if (remoteInput == null)
        return;

    final long[] recipientIds = intent.getLongArrayExtra(RECIPIENT_IDS_EXTRA);
    final CharSequence responseText = remoteInput.getCharSequence(MessageNotifier.EXTRA_VOICE_REPLY);
    final Recipients recipients = RecipientFactory.getRecipientsForIds(context, recipientIds, false);

    if (masterSecret != null && responseText != null) {
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                long threadId;

                if (recipients.isGroupRecipient()) {
                    OutgoingMediaMessage reply = new OutgoingMediaMessage(context, recipients, new PduBody(),
                            responseText.toString(), 0);
                    threadId = MessageSender.send(context, masterSecret, reply, -1, false);
                } else {
                    OutgoingTextMessage reply = new OutgoingTextMessage(recipients, responseText.toString());
                    threadId = MessageSender.send(context, masterSecret, reply, -1, false);
                }

                DatabaseFactory.getThreadDatabase(context).setRead(threadId);
                MessageNotifier.updateNotification(context, masterSecret);

                return null;
            }
        }.execute();
    }

}