本文整理汇总了Java中android.content.Intent.getLongArrayExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getLongArrayExtra方法的具体用法?Java Intent.getLongArrayExtra怎么用?Java Intent.getLongArrayExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getLongArrayExtra方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleResolvedMedia
import android.content.Intent; //导入方法依赖的package包/类
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);
}
}
示例2: openDownload
import android.content.Intent; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例3: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
示例4: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
示例5: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
示例6: getValue
import android.content.Intent; //导入方法依赖的package包/类
/**
* 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;
}
示例7: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
示例8: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@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();
}
}
}
}
示例9: fromIntent
import android.content.Intent; //导入方法依赖的package包/类
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);
}