Java Code Examples for android.content.Intent.getLongArrayExtra()

The following are Jave code examples for showing how to use getLongArrayExtra() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: PeSanKita-android   File: ShareActivity.java   View Source Code Vote up 7 votes
private void handleResolvedMedia(Intent intent, boolean animate) {
  long   threadId         = intent.getLongExtra(EXTRA_THREAD_ID, -1);
  long[] recipientIds     = intent.getLongArrayExtra(EXTRA_RECIPIENT_IDS);
  int    distributionType = intent.getIntExtra(EXTRA_DISTRIBUTION_TYPE, -1);

  boolean hasResolvedDestination = threadId != -1 && recipientIds != null && distributionType != -1;

  if (!hasResolvedDestination && animate) {
    ViewUtil.fadeIn(fragmentContainer, 300);
    ViewUtil.fadeOut(progressWheel, 300);
  } else if (!hasResolvedDestination) {
    fragmentContainer.setVisibility(View.VISIBLE);
    progressWheel.setVisibility(View.GONE);
  } else {
    createConversation(threadId, RecipientFactory.getRecipientsForIds(this, recipientIds, true), distributionType);
  }
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: DownloadBroadcastReceiver.java   View Source Code Vote up 7 votes
/**
 * Called to open a given download item that is downloaded by the android DownloadManager.
 * @param context Context of the receiver.
 * @param intent Intent from the android DownloadManager.
 */
private void openDownload(final Context context, Intent intent) {
    long ids[] =
            intent.getLongArrayExtra(DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS);
    if (ids == null || ids.length == 0) {
        DownloadManagerService.openDownloadsPage(context);
        return;
    }
    long id = ids[0];
    Uri uri = DownloadManagerDelegate.getContentUriFromDownloadManager(context, id);
    if (uri == null) {
        // Open the downloads page
        DownloadManagerService.openDownloadsPage(context);
    } else {
        String downloadFilename = IntentUtils.safeGetStringExtra(
                intent, DownloadNotificationService.EXTRA_DOWNLOAD_FILE_PATH);
        boolean isSupportedMimeType =  IntentUtils.safeGetBooleanExtra(
                intent, DownloadNotificationService.EXTRA_IS_SUPPORTED_MIME_TYPE, false);
        Intent launchIntent = DownloadManagerService.getLaunchIntentFromDownloadId(
                context, downloadFilename, id, isSupportedMimeType);
        if (!DownloadUtils.fireOpenIntentForDownload(context, launchIntent)) {
            DownloadManagerService.openDownloadsPage(context);
        }
    }
}
 
Example 3
Project: Cable-Android   File: DeleteNotificationReceiver.java   View Source Code Vote up 7 votes
@Override
public void onReceive(final Context context, Intent intent) {
  if (DELETE_NOTIFICATION_ACTION.equals(intent.getAction())) {
    MessageNotifier.clearReminder(context);

    final long[]    ids = intent.getLongArrayExtra(EXTRA_IDS);
    final boolean[] mms = intent.getBooleanArrayExtra(EXTRA_MMS);

    if (ids == null  || mms == null || ids.length != mms.length) return;

    new AsyncTask<Void, Void, Void>() {
      @Override
      protected Void doInBackground(Void... params) {
        for (int i=0;i<ids.length;i++) {
          if (!mms[i]) DatabaseFactory.getSmsDatabase(context).markAsNotified(ids[i]);
          else         DatabaseFactory.getMmsDatabase(context).markAsNotified(ids[i]);
        }

        return null;
      }
    }.execute();
  }
}
 
Example 4
Project: Cable-Android   File: ShareActivity.java   View Source Code Vote up 7 votes
private void handleResolvedMedia(Intent intent, boolean animate) {
  long   threadId         = intent.getLongExtra(EXTRA_THREAD_ID, -1);
  long[] recipientIds     = intent.getLongArrayExtra(EXTRA_RECIPIENT_IDS);
  int    distributionType = intent.getIntExtra(EXTRA_DISTRIBUTION_TYPE, -1);

  boolean hasResolvedDestination = threadId != -1 && recipientIds != null && distributionType != -1;

  if (!hasResolvedDestination && animate) {
    ViewUtil.fadeIn(fragmentContainer, 300);
    ViewUtil.fadeOut(progressWheel, 300);
  } else if (!hasResolvedDestination) {
    fragmentContainer.setVisibility(View.VISIBLE);
    progressWheel.setVisibility(View.GONE);
  } else {
    createConversation(threadId, RecipientFactory.getRecipientsForIds(this, recipientIds, true), distributionType);
  }
}
 
Example 5
Project: PeSanKita-android   File: MarkReadReceiver.java   View Source Code Vote up 6 votes
@Override
protected void onReceive(final Context context, Intent intent, @Nullable final MasterSecret masterSecret)
{
  if (!CLEAR_ACTION.equals(intent.getAction()))
    return;

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

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

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

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

        process(context, messageIdsCollection);

        MessageNotifier.updateNotification(context, masterSecret);

        return null;
      }
    }.execute();
  }
}
 
Example 6
Project: PeSanKita-android   File: AndroidAutoHeardReceiver.java   View Source Code Vote up 6 votes
@Override
protected void onReceive(final Context context, Intent intent,
                         @Nullable final MasterSecret masterSecret)
{
  if (!HEARD_ACTION.equals(intent.getAction()))
    return;

  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);
          DatabaseFactory.getThreadDatabase(context).setLastSeen(threadId);

          messageIdsCollection.addAll(messageIds);
        }

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

        return null;
      }
    }.execute();
  }
}
 
Example 7
Project: smartkey   File: IntentValueGetter.java   View Source Code Vote up 6 votes
/**
 * Get a value from an intent by a giving class and key.
 * @param intent
 *  the source intent
 * @param key
 *  the key of the value
 * @param clz
 *  the class of the value
 * @return
 *  the value from the source intent
 */
public static Object getValue(Intent intent, String key, Class<?> clz) {
    Object value = null;
    // Cause it is not an easy job to handle inheritance in apt, it is a lot easier to put the code in the Android environment.
    if(Bundle.class.isAssignableFrom(clz)) {
        // bundle implements parcelable, so it should place before parcelable.
        value = intent.getBundleExtra(key);
    } else if(Parcelable.class.isAssignableFrom(clz)) {
        value = intent.getParcelableExtra(key);
    } else if(Parcelable[].class.isAssignableFrom(clz)) {
        value = intent.getParcelableArrayExtra(key);
    } else if(boolean[].class.isAssignableFrom(clz)) {
        value = intent.getBooleanArrayExtra(key);
    } else if(byte[].class.isAssignableFrom(clz)) {
        value = intent.getByteArrayExtra(key);
    } else if(short[].class.isAssignableFrom(clz)) {
        value = intent.getShortArrayExtra(key);
    } else if(char[].class.isAssignableFrom(clz)) {
        value = intent.getCharArrayExtra(key);
    } else if(int[].class.isAssignableFrom(clz)) {
        value = intent.getIntArrayExtra(key);
    } else if(long[].class.isAssignableFrom(clz)) {
        value = intent.getLongArrayExtra(key);
    } else if(float[].class.isAssignableFrom(clz)) {
        value = intent.getFloatArrayExtra(key);
    } else if(double[].class.isAssignableFrom(clz)) {
        value = intent.getDoubleArrayExtra(key);
    } else if(String[].class.isAssignableFrom(clz)) {
        value = intent.getStringArrayExtra(key);
    } else if(CharSequence[].class.isAssignableFrom(clz)) {
        value = intent.getCharSequenceArrayExtra(key);
    } else if(Serializable.class.isAssignableFrom(clz)) {
        // some of the above are assignable for serializable, so serializable should be in the last place.
        value = intent.getSerializableExtra(key);
    } else {
        throw new RuntimeException(clz + " is not compatible with intent (key=" + key + ")");
    }

    return value;
}
 
Example 8
Project: Cable-Android   File: MarkReadReceiver.java   View Source Code Vote up 6 votes
@Override
protected void onReceive(final Context context, Intent intent, @Nullable final MasterSecret masterSecret)
{
  if (!CLEAR_ACTION.equals(intent.getAction()))
    return;

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

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

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

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

        process(context, messageIdsCollection);

        MessageNotifier.updateNotification(context, masterSecret);

        return null;
      }
    }.execute();
  }
}
 
Example 9
Project: Cable-Android   File: AndroidAutoHeardReceiver.java   View Source Code Vote up 6 votes
@Override
protected void onReceive(final Context context, Intent intent,
                         @Nullable final MasterSecret masterSecret)
{
  if (!HEARD_ACTION.equals(intent.getAction()))
    return;

  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();
  }
}
 
Example 10
Project: GCSApp   File: DownloadUtil.java   View Source Code Vote up 6 votes
@Override
public void onReceive(Context context, Intent intent) {
    //Notification点击
    if (intent.getAction().equals(DownloadManager.ACTION_NOTIFICATION_CLICKED)) {
        String extraID = DownloadManager.EXTRA_NOTIFICATION_CLICK_DOWNLOAD_IDS;
        long[] references = intent.getLongArrayExtra(extraID);
        for (long reference : references)
            if (reference == myReference) {
            }
    }
    //下载完成
    if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
        long completeDownloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
        if (completeDownloadId == myReference) {
            Cursor cursor = downloadManager.query(new DownloadManager.Query()
                    .setFilterById(completeDownloadId));
            cursor.moveToFirst();
            String filePath = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
            cursor.close();
            if (filePath != null) {
                if (filePath.contains(context.getPackageName())) {
                    if (filePath.endsWith("apk")) {
                        AppUtils.installAPK(context, filePath.trim().substring(7));
                    } else {
                        Toast.makeText(context, "下载完成", Toast.LENGTH_SHORT).show();
                    }
                }
            } else {
                Toast.makeText(context, "网络不给力", Toast.LENGTH_SHORT).show();
            }
        }
    }
}
 
Example 11
Project: financisto1-holo   File: QifExportOptions.java   View Source Code Vote up 6 votes
public static QifExportOptions fromIntent(Intent data) {
    WhereFilter filter = WhereFilter.fromIntent(data);
    Currency currency = CurrencyExportPreferences.fromIntent(data, "qif");
    String dateFormat = data.getStringExtra(QifExportActivity.QIF_EXPORT_DATE_FORMAT);
    long[] selectedAccounts = data.getLongArrayExtra(QifExportActivity.QIF_EXPORT_SELECTED_ACCOUNTS);
    boolean uploadToDropbox = data.getBooleanExtra(QifExportActivity.QIF_EXPORT_UPLOAD_TO_DROPBOX, false);
    return new QifExportOptions(currency, dateFormat, selectedAccounts, filter, uploadToDropbox);
}