List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.stfalcon.hromadskyipatrol.services.UploadService.java
private void handleUploadVideoByStorage(Intent intent) { if (intent.hasExtra(Extras.ID) && intent.hasExtra(Extras.URL_VIDEO) && intent.hasExtra(Extras.DATE)) { Date date = (Date) intent.getSerializableExtra(Extras.DATE); String urlVideo = intent.getStringExtra(Extras.URL_VIDEO); String id = intent.getStringExtra(Extras.ID); uploadVideo(urlVideo, id, date); }/*from ww w .j av a 2 s . c om*/ }
From source file:com.nexmo.sdk.sample.verifysample_pushenabled.gcm.GcmRegistrationIntentService.java
@Override protected void onHandleIntent(Intent intent) { // Synchronize this part in case multiple refresh operations occur. if (intent != null && ACTION_REGISTER.equals(intent.getAction()) && intent.hasExtra(INTENT_EXTRA_SENDER_ID)) synchronized (TAG) { InstanceID instanceID = InstanceID.getInstance(this); String sender_id = intent.getExtras().getString(INTENT_EXTRA_SENDER_ID); String token = null;//from w w w . jav a2 s .c o m try { token = instanceID.getToken(sender_id, GoogleCloudMessaging.INSTANCE_ID_SCOPE); Log.d(TAG, "GCM registration token: " + token); } catch (IOException e) { Log.e(TAG, "GCM registration token failed", e); } // Notify Application class that registration has completed, so NexmoClient can update the GcmRegistrationToken. Intent registrationComplete = new Intent(REGISTRATION_COMPLETE); intent.putExtra(INTENT_EXTRA_PUSH_TOKEN, token); LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); } }
From source file:com.deliciousdroid.activity.AddBookmark.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add_bookmark); Intent intent = getIntent(); if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) { bookmark = new Bookmark(); ShareCompat.IntentReader reader = ShareCompat.IntentReader.from(this); String url = StringUtils.getUrl(reader.getText().toString()); bookmark.setUrl(url);// w w w. j a va2 s. c o m if (reader.getSubject() != null) bookmark.setDescription(reader.getSubject()); if (url.equals("")) { Toast.makeText(this, R.string.add_bookmark_invalid_url, Toast.LENGTH_LONG).show(); } if (intent.hasExtra(Constants.EXTRA_DESCRIPTION)) { bookmark.setDescription(intent.getStringExtra(Constants.EXTRA_DESCRIPTION)); } bookmark.setNotes(intent.getStringExtra(Constants.EXTRA_NOTES)); bookmark.setTagString(intent.getStringExtra(Constants.EXTRA_TAGS)); bookmark.setShared(!intent.getBooleanExtra(Constants.EXTRA_PRIVATE, privateDefault)); try { Bookmark old = BookmarkManager.GetByUrl(bookmark.getUrl(), this); bookmark = old.copy(); } catch (Exception e) { } } else if (Intent.ACTION_EDIT.equals(intent.getAction())) { int id = Integer.parseInt(intent.getData().getLastPathSegment()); try { bookmark = BookmarkManager.GetById(id, this); oldBookmark = bookmark.copy(); update = true; } catch (ContentNotFoundException e) { e.printStackTrace(); } } if (update) setTitle(getString(R.string.add_bookmark_edit_title)); else setTitle(getString(R.string.add_bookmark_add_title)); frag = (AddBookmarkFragment) getSupportFragmentManager().findFragmentById(R.id.add_bookmark_fragment); frag.loadBookmark(bookmark, oldBookmark); }
From source file:com.tencent.wetest.activity.DataDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_data_detail); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from ww w .j a v a 2 s . c o m toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintColor(Color.parseColor("#3367d6")); tintManager.setStatusBarTintEnabled(true); } tvDataDetail = (TextView) findViewById(R.id.dataDetail); Intent intent = this.getIntent(); if (intent != null && intent.hasExtra("filename")) { mLogName = intent.getStringExtra("filename"); } String fileDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/wetest"; mLogFile = new File(fileDir + "/" + mLogName); tvFilePathName = (TextView) findViewById(R.id.filePathName); tvFilePathName.setText(mLogFile.getAbsolutePath()); new Thread(new Runnable() { @Override public void run() { try { dataContent = ReportUtil.readFileContent(mLogFile); } catch (Exception e) { Logger.error("readFileContent error :" + e.toString()); e.printStackTrace(); } Message msg = mHandler.obtainMessage(); mHandler.sendMessage(msg); } }).start(); }
From source file:com.stfalcon.hromadskyipatrol.services.UploadService.java
private void handleUploadVideoByDB(Intent intent) { if (intent.hasExtra(IntentUtilities.VIDEO_ID)) { DatabasePatrol db = DatabasePatrol.get(this); String videoId = intent.getStringExtra(IntentUtilities.VIDEO_ID); VideoItem videoItem = db.getVideo(videoId); if (videoItem != null) { if (videoItem.getState() != VideoItem.State.UPLOADED) { UserItem user = ProjectPreferencesManager.getUser(this); updateItem(videoItem.getId(), VideoItem.State.SENDING, db); VideoAnswer answer = uploadVideo(videoItem, user); updateItem(answer.getId(), VideoItem.State.from(answer.getState()), db); }/*ww w . j av a 2s .c om*/ } } else { tryToSendAllVideo(); } }
From source file:com.example.awesomedogs.ui.MainActivityTest.java
public void testClickingDogOpensDetails() { // Clicking on any dog should open the details activity ListView listView = getListView(); listView.performItemClick(null, 0, 0); Intent intent = getStartedActivityIntent(); assertNotNull(intent);/* w w w . jav a2 s .c o m*/ assertEquals(DogDetailActivity.class.getName(), intent.getComponent().getClassName()); assertTrue(intent.hasExtra(DogDetailActivity.EXTRA_DOG_ID)); }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.VervangerDialogActivity.java
/** * * @param savedInstanceState/* w w w .j a v a2 s . c om*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set the nfc scan layout setContentView(R.layout.vervanger_dialog_activity); // bind the elements to the view ButterKnife.bind(this); // get the vervanger id from the activity intent Intent intent = getIntent(); if ((intent != null) && (intent.hasExtra(DagvergunningFragmentKoopman.VERVANGER_INTENT_EXTRA_VERVANGER_ID))) { int vervangerId = intent.getIntExtra(DagvergunningFragmentKoopman.VERVANGER_INTENT_EXTRA_VERVANGER_ID, 0); if (vervangerId != 0) { mVervangerId = vervangerId; } } // create an adapter for the koopmannen listview mKoopmannenAdapter = new VervangerKoopmannenAdapter(this); mKoopmannenListView.setAdapter(mKoopmannenAdapter); // inititate loading the dagvergunningen from the database with the given koopman id getSupportLoaderManager().initLoader(KOOPMANNEN_LOADER, null, this); // disable upper-casing the wizard menu buttons mCancelButton.setTransformationMethod(null); }
From source file:ar.com.martineo14.spotifystreamer2.ui.fragment.ArtistDetailActivityFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_artist_detail, container, false); listView = (ListView) rootView.findViewById(R.id.list_artist_top_ten); if (savedInstanceState != null) { tracksModelResult = savedInstanceState.getParcelableArrayList(Constants.TRACK_MODEL_RESULT); if (tracksModelResult != null) { tracksListAdapter = new ArtistTracksListAdapter(getActivity(), tracksModelResult); listView.setAdapter(tracksListAdapter); }//w w w . jav a2 s . c o m } else { Intent intent = getActivity().getIntent(); if (intent != null && intent.hasExtra(Constants.ARTIST_NAME)) { mArtistIDStr = intent.getStringExtra(Constants.ARTIST_ID); mArtistNameSrt = intent.getStringExtra(Constants.ARTIST_NAME); ArtistTopTenTask artistTopTenTask = new ArtistTopTenTask(); artistTopTenTask.execute(mArtistIDStr); } Bundle bundle = getArguments(); if (bundle != null) { mArtistIDStr = bundle.getString(Constants.ARTIST_ID); mArtistNameSrt = bundle.getString(Constants.ARTIST_NAME); ArtistTopTenTask artistTopTenTask = new ArtistTopTenTask(); artistTopTenTask.execute(mArtistIDStr); } } return rootView; }
From source file:com.pindroid.activity.AddBookmark.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.add_bookmark); Intent intent = getIntent(); if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.hasExtra(Intent.EXTRA_TEXT)) { // we don't need to ask for an account if the intent was generated internally if (!intent.hasExtra(Constants.EXTRA_INTERNAL) || !intent.getBooleanExtra(Constants.EXTRA_INTERNAL, true)) requestAccount();/*w w w . j a v a2 s. c o m*/ bookmark = new Bookmark(); loadBookmarkFromShareIntent(); if (bookmark.getUrl().equals("")) { Toast.makeText(this, R.string.add_bookmark_invalid_url, Toast.LENGTH_LONG).show(); } findExistingBookmark(); } else if (Intent.ACTION_EDIT.equals(intent.getAction())) { int id = Integer.parseInt(intent.getData().getLastPathSegment()); try { bookmark = BookmarkManager.GetById(id, this); oldBookmark = bookmark.copy(); update = true; } catch (ContentNotFoundException e) { e.printStackTrace(); } } if (update) setTitle(getString(R.string.add_bookmark_edit_title)); else setTitle(getString(R.string.add_bookmark_add_title)); frag = (AddBookmarkFragment) getSupportFragmentManager().findFragmentById(R.id.add_bookmark_fragment); frag.loadBookmark(bookmark, oldBookmark); frag.setUsername(app.getUsername()); }
From source file:com.vantiv.android.gms.samples.wallet.ConfirmationActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_CHANGE_MASKED_WALLET: if (resultCode == Activity.RESULT_OK && data.hasExtra(WalletConstants.EXTRA_MASKED_WALLET)) { mMaskedWallet = data.getParcelableExtra(WalletConstants.EXTRA_MASKED_WALLET); ((FullWalletConfirmationButtonFragment) getResultTargetFragment()) .updateMaskedWallet(mMaskedWallet); }/*from w ww . j a v a 2s . c o m*/ // you may also want to use the new masked wallet data here, say to recalculate // shipping or taxes if shipping address changed break; case WalletConstants.RESULT_ERROR: int errorCode = data.getIntExtra(WalletConstants.EXTRA_ERROR_CODE, 0); handleError(errorCode); break; default: super.onActivityResult(requestCode, resultCode, data); break; } }