當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.getLongExtra方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:22,代碼來源:PurgeAccountActivity.java

示例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...");
      }
    }
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:25,代碼來源:UpdateApkReadyListener.java

示例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);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:20,代碼來源:WearReplyReceiver.java

示例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;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:18,代碼來源:MemoryTracker.java

示例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"));
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:22,代碼來源:UserEventActivity.java

示例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());
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:26,代碼來源:GroupEditActivity.java

示例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;
        }
    }
}
 
開發者ID:gothalo,項目名稱:Android-2017,代碼行數:25,代碼來源:ViewNoteActivity.java

示例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;
        }
    }
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:32,代碼來源:OpenPgpKeyPreference.java

示例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);
}
 
開發者ID:liying2008,項目名稱:Simpler,代碼行數:38,代碼來源:WBStatusesActivity.java

示例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));
    }
}
 
開發者ID:huazhouwang,項目名稱:Synapse,代碼行數:28,代碼來源:MainService.java

示例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);
}
 
開發者ID:PaulKlinger,項目名稱:Sprog-App,代碼行數:33,代碼來源:PoemsLoader.java

示例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();
            }
        }
 
開發者ID:BittleDragon,項目名稱:MyRepository,代碼行數:28,代碼來源:DownloadService.java

示例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);
    }
}
 
開發者ID:ifadai,項目名稱:SuperNote,代碼行數:9,代碼來源:NoteMainPresenter.java

示例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();
    }
}
 
開發者ID:konachan700,項目名稱:SSHFileManager,代碼行數:41,代碼來源:SSHServersFragment.java

示例15: getIntentPatchCostTime

import android.content.Intent; //導入方法依賴的package包/類
public static long getIntentPatchCostTime(Intent intent) {
    return intent.getLongExtra(INTENT_PATCH_COST_TIME, 0);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:ShareIntentUtil.java


注:本文中的android.content.Intent.getLongExtra方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。