本文整理汇总了Java中android.content.Intent.getLongExtra方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getLongExtra方法的具体用法?Java Intent.getLongExtra怎么用?Java Intent.getLongExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getLongExtra方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAccount
import android.content.Intent; //导入方法依赖的package包/类
private void loadAccount() {
Intent intent = getIntent();
if (intent == null) {
Toast.makeText(this, "No account specified", Toast.LENGTH_SHORT).show();
finish();
return;
}
long accountId = intent.getLongExtra(ACCOUNT_ID, -1);
if (accountId <= 0) {
Toast.makeText(this, "Invalid account specified", Toast.LENGTH_SHORT).show();
finish();
return;
}
account = em.getAccount(accountId);
if (account == null) {
Toast.makeText(this, "No account found", Toast.LENGTH_SHORT).show();
finish();
}
}
示例2: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.w(TAG, "onReceive()");
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) {
long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -2);
if (downloadId == TextSecurePreferences.getUpdateApkDownloadId(context)) {
Uri uri = getLocalUriForDownloadId(context, downloadId);
String encodedDigest = TextSecurePreferences.getUpdateApkDigest(context);
if (uri == null) {
Log.w(TAG, "Downloaded local URI is null?");
return;
}
if (isMatchingDigest(context, downloadId, encodedDigest)) {
displayInstallNotification(context, uri);
} else {
Log.w(TAG, "Downloaded APK doesn't match digest...");
}
}
}
}
示例3: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
ApplicationLoader.postInitApplication();
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
if (remoteInput == null) {
return;
}
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, null, null, null);
MessagesController.getInstance().markDialogAsRead(dialog_id, max_id, max_id, 0, true, false);
}
示例4: onStartCommand
import android.content.Intent; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.v(TAG, "Received start id " + startId + ": " + intent);
if (intent != null) {
if (TestingUtils.ACTION_START_TRACKING.equals(intent.getAction())) {
final int pid = intent.getIntExtra("pid", -1);
final String name = intent.getStringExtra("name");
final long start = intent.getLongExtra("start", System.currentTimeMillis());
startTrackingProcess(pid, name, start);
}
}
mHandler.sendEmptyMessage(MSG_START);
return START_STICKY;
}
示例5: initWidget
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void initWidget() {
super.initWidget();
mEmptyLayout.setOnLayoutClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mEmptyLayout.getErrorState() != EmptyLayout.NETWORK_LOADING) {
mEmptyLayout.setErrorType(EmptyLayout.NETWORK_LOADING);
mPresenter.onRefreshing();
}
}
});
UserEventFragment fragment = UserEventFragment.newInstance();
addFragment(R.id.lay_container, fragment);
Intent intent = getIntent();
mPresenter = new UserEventPresenter(fragment,
this,
intent.getLongExtra("authorId", 0),
intent.getStringExtra("authorName"));
}
示例6: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_group_edit);
ButterKnife.bind(this);
Intent intent = getIntent();
mType = intent.getIntExtra(INTENT_TYPE, TYPE_EDIT);
if (mType == TYPE_EDIT) {
mTvTitle.setText(R.string.title_edit_group);
mGid = intent.getLongExtra(INTENT_GID, 0L);
mPosition = intent.getIntExtra(INTENT_POSITION, 0);
mGroupName = intent.getStringExtra(INTENT_NAME);
mDesc = intent.getStringExtra(INTENT_DESC);
mEtGroupName.setText(mGroupName);
mEtGroupName.setSelection(mGroupName.length());
mEtGroupDesc.setText(mDesc);
mEtGroupDesc.setSelection(mDesc.length());
} else if (mType == TYPE_ADD) {
mTvTitle.setText(R.string.title_add_group);
}
mGroupMgrOp = new GroupMgrOp(this);
mGroupMgrOp.setOnGroupCreateListener(new MyGroupCreateListener());
mGroupMgrOp.setOnGroupUpdateListener(new MyGroupUpdateListener());
}
示例7: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
/**
* procesa el retorno del borrado de una nota.
* @param requestCode codigo con el que se llama a la activity nueva
* @param resultCode resultado de ejecución de la activity
* @param data datos adicionales en forma de intent
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == AppConstants.REQUEST_CODE_EDIT) {
switch (resultCode) {
case AppConstants.RETURN_CODE_NOTE_DELETED :
Toast.makeText(this, R.string.delete_note_ok, Toast.LENGTH_LONG).show();
this.finish();
break;
case AppConstants.RETURN_CODE_NOTE_EDITED :
long idNote = data.getLongExtra(AppConstants.EXTRA_NOTE_ID, 0);
loadAndShowNote(idNote);
Toast.makeText(this, R.string.edit_note_ok, Toast.LENGTH_LONG).show();
break;
}
}
}
示例8: onReturn
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReturn(Intent result) {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS: {
long keyId = result.getLongExtra(OpenPgpApi.EXTRA_SIGN_KEY_ID, NO_KEY);
save(keyId);
break;
}
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
try {
Activity act = (Activity) getContext();
act.startIntentSenderFromChild(
act, pi.getIntentSender(),
requestCode, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.e(OpenPgpApi.TAG, "SendIntentException", e);
}
break;
}
case OpenPgpApi.RESULT_CODE_ERROR: {
OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
Log.e(OpenPgpApi.TAG, "RESULT_CODE_ERROR: " + error.getMessage());
break;
}
}
}
示例9: onCreate
import android.content.Intent; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wb_statuses);
ButterKnife.bind(this);
// 每次刷新微博数
mRefreshCount = BaseSettings.sSettings.refreshCount;
Intent intent = getIntent();
mUid = intent.getLongExtra(INTENT_UID, 0L);
String name = intent.getStringExtra(INTENT_NAME);
mTvTitle.setText(getString(R.string.title_statuses, name));
mSwipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
// 刷新微博,加载最新微博
loadStatuses(0, true);
mSwipeRefresh.setRefreshing(true);
}
});
// 创建适配器
mAdapter = new StatusListAdapter(WBStatusesActivity.this, null);
mSwipeRefresh.setRecyclerViewAndAdapter(mRvStatuses, mAdapter);
mSwipeRefresh.setOnLoadingListener(new DSwipeRefresh.OnLoadingListener() {
@Override
public void onLoading() {
if (mMaxId != 0) {
// 加载更早微博
mAdapter.setFooterInfo(getString(R.string.data_loading));
loadStatuses(mMaxId, false);
}
}
});
loadStatuses(0, true); // 加载最新微博
mSwipeRefresh.setRefreshing(true);
}
示例10: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
final long downloadedId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
final DownloadManager.Query query = new DownloadManager.Query();
query.setFilterById(downloadedId);
final Cursor cursor = mDownloadManager.query(query);
if (cursor.moveToFirst() &&
DownloadManager.STATUS_SUCCESSFUL == cursor.getInt(
cursor.getColumnIndex(DownloadManager.COLUMN_STATUS))) {
mIds.remove(downloadedId);
if (mIds.isEmpty()) {
Global.getInstance().getBus()
.post(new MSNEvent<>(MSNEvent.DOWNLOAD_COMPLETE, true));
}
} else {
for (Long id : mIds) {
mDownloadManager.remove(id);
}
Global.getInstance().getBus()
.post(new MSNEvent<>(MSNEvent.DOWNLOAD_COMPLETE, false));
}
}
示例11: loadPoems
import android.content.Intent; //导入方法依赖的package包/类
public static void loadPoems(final Context context, final MainPresenter presenter) {
File poems_file = new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
"poems.json");
File poems_old_file = new File(context.getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS),
"poems_old.json");
if (poems_file.exists()) {
poems_file.renameTo(poems_old_file);
}
String url = "https://almoturg.com/poems.json";
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url));
request.setDescription("Sprog poems");
request.setTitle("Sprog");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE);
request.setDestinationInExternalFilesDir(context, Environment.DIRECTORY_DOWNLOADS,
"poems.json");
// get download service and enqueue file
DownloadManager manager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
receiver = new BroadcastReceiver() {
public void onReceive(Context ctxt, Intent intent) {
if (intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) != downloadID){return;}
context.unregisterReceiver(PoemsLoader.receiver);
PoemsLoader.receiver = null;
presenter.downloadComplete();
}
};
context.registerReceiver(receiver,
new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
downloadID = manager.enqueue(request);
}
示例12: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.e("收到的action", intent.getAction());
//判断是否下载完成的广播
if (intent.getAction().equals(DownloadManager.ACTION_DOWNLOAD_COMPLETE)) {
// Toast.makeText(context, "下载完成", Toast.LENGTH_SHORT).show();
// timer.cancel();
remoteViews.setTextViewText(R.id.tv_title, "产品医院下载完成");
notifyProgress(100);
//获取下载的文件id
long downId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
Uri downloadFileUri = manager.getUriForDownloadedFile(downId);
Log.e("下载的apk路径", downloadFileUri.getPath());
if (manager.getUriForDownloadedFile(downId) != null) {
//自动安装apk
Log.e("自动安装apk", "执行了");
installAPK(manager.getUriForDownloadedFile(downId), context);
// installAPK(context);
} else {
Toast.makeText(context, "下载失败", Toast.LENGTH_SHORT).show();
}
//停止服务并关闭广播
DownloadService.this.stopSelf();
}
}
示例13: resultForAddNote
import android.content.Intent; //导入方法依赖的package包/类
private void resultForAddNote(int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
String noteId = data.getStringExtra("note_id");
String content = data.getStringExtra("note_content");
long modifiedTime = data.getLongExtra("modified_time", 0);
addNote(noteId, content, modifiedTime);
}
}
示例14: onActivityResult
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
final DBHelper dbHelper = new DBHelper(this.getContext());
final SQLiteDatabase db = dbHelper.getWritableDatabase();
final long id;
if (requestCode == 0) {
switch (resultCode) {
case 0:
break;
case 1:
final ContentValues cv = new ContentValues();
cv.put("host", data.getStringExtra("host"));
cv.put("username", data.getStringExtra("username"));
cv.put("password", data.getStringExtra("password"));
cv.put("port", data.getStringExtra("port"));
cv.put("initDir", data.getStringExtra("initDir"));
cv.put("userText", data.getStringExtra("userText"));
id = data.getLongExtra("id", Integer.MAX_VALUE);
if (id == Integer.MAX_VALUE) {
db.insert("sshServers", null, cv);
} else {
db.update("sshServers", cv, "id=?", new String[] { (id+"") });
}
break;
case 2:
id = data.getLongExtra("id", Integer.MAX_VALUE);
if (id != Integer.MAX_VALUE) {
db.delete("sshServers", "id=?", new String[] { (id+"") });
}
break;
}
dbHelper.close();
refresh();
}
}
示例15: getIntentPatchCostTime
import android.content.Intent; //导入方法依赖的package包/类
public static long getIntentPatchCostTime(Intent intent) {
return intent.getLongExtra(INTENT_PATCH_COST_TIME, 0);
}