List of usage examples for android.os Bundle get
@Nullable
public Object get(String key)
From source file:io.v.android.apps.syncslides.SlideListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // See comment at the top of fragment_slide_list.xml. ((PresentationActivity) getActivity()).setUiImmersive(false); // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_slide_list, container, false); if (!mInitialized) { mInitialized = true;//from ww w . j ava 2s .co m Bundle bundle = savedInstanceState; if (bundle == null) { bundle = getArguments(); } mDeckId = bundle.getString(DECK_ID_KEY); Log.d(TAG, "onCreateView - Got deckId = " + mDeckId); mRole = (Role) bundle.get(ROLE_KEY); } // Clicking on the fab starts the presentation. final FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.play_presentation_fab); if (mRole == Role.BROWSER) { fab.setVisibility(View.VISIBLE); } fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mRole = Role.PRESENTER; fab.setVisibility(View.INVISIBLE); PresentationActivity activity = (PresentationActivity) v.getContext(); activity.startPresentation(); } }); mRecyclerView = (RecyclerView) rootView.findViewById(R.id.slide_list); mRecyclerView.setHasFixedSize(true); mLayoutManager = new LinearLayoutManager(container.getContext(), LinearLayoutManager.VERTICAL, false); mRecyclerView.setLayoutManager(mLayoutManager); getActivity().setTitle(SLIDE_LIST_TITLE); return rootView; }
From source file:com.capstonecontrol.AccountsActivity.java
private String getAuthToken(AccountManagerFuture<Bundle> future) { try {//from w w w . j a v a2 s . c om Bundle authTokenBundle = future.getResult(); String authToken = authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString(); return authToken; } catch (Exception e) { Log.w(TAG, "Got Exception " + e); return null; } }
From source file:com.liuwuping.sm.ui.repodetail.RepoDetailActivity.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_repodetail); setSupportActionBar(toolbar);//from w w w . ja v a 2 s. c o m ActionBar bar = getSupportActionBar(); bar.setDisplayHomeAsUpEnabled(true); bar.setDisplayShowHomeEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setHomeButtonEnabled(true); Bundle bundle = getIntent().getExtras(); repo = (Repo) bundle.get("repo"); String[] names = repo.getFull_name().split("/"); login = names[0]; repoName = names[1]; appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { boolean isShow = false; int scrollRange = -1; @Override public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (scrollRange == -1) { scrollRange = appBarLayout.getTotalScrollRange(); } if (scrollRange + verticalOffset == 0) { collapsingToolbarLayout.setTitle(repoName); isShow = true; } else if (isShow) { collapsingToolbarLayout.setTitle(""); isShow = false; } } }); repoNameTv.setText(repoName); SpannableString spannableString = new SpannableString(login); spannableString.setSpan(new UnderlineSpan(), 0, login.length(), 0); repoOwnerTv.setText(spannableString); starTv.setText(String.valueOf(repo.getStargazers_count())); forkTv.setText(String.valueOf(repo.getForks())); issueTv.setText(String.valueOf(repo.getOpen_issues())); recyclerView.setLayoutManager(new LinearLayoutManager(this)); SimpleDividerDecoration decoration = new SimpleDividerDecoration(this); recyclerView.addItemDecoration(decoration); recyclerView.setHasFixedSize(true); adapter = new TagAdapter(); recyclerView.setAdapter(adapter); RecyclerItemClickSupport.addTo(recyclerView) .setOnItemClickListener(new RecyclerItemClickSupport.OnItemClickListener() { @Override public void onItemClicked(RecyclerView recyclerView, int position, View v) { Tag tag = tagList.get(position); repo.setTagId(tag.getId()); presenter.addRepoToTag(repo); } }); presenter = new RepoDetailPresenter(this); presenter.getReadMeUrl(login, repoName); presenter.getAvatarUrl(login); presenter.isStar(login, repoName); presenter.loadTags(); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); webViewProgressBar.setVisibility(View.INVISIBLE); } }); }
From source file:com.arthackday.killerapp.util.Util.java
public String getGoogleAuth(String type) { AccountManager mgr = AccountManager.get(activity); Account[] accts = mgr.getAccountsByType("com.google"); if (accts.length == 0) { return null; }/*from w w w .j ava 2 s . c o m*/ try { Account acct = accts[0]; Log.d(LOG_TAG, "acct name=" + acct.name); AccountManagerFuture<Bundle> accountManagerFuture = mgr.getAuthToken(acct, type, null, activity, null, null); Bundle authTokenBundle = accountManagerFuture.getResult(); if (authTokenBundle.containsKey(AccountManager.KEY_INTENT)) { Intent authRequestIntent = (Intent) authTokenBundle.get(AccountManager.KEY_INTENT); activity.startActivity(authRequestIntent); } return authTokenBundle.get(AccountManager.KEY_AUTHTOKEN).toString(); } catch (OperationCanceledException e) { e.printStackTrace(); } catch (AuthenticatorException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:com.ute.bihapi.wydarzeniatekstowe.thirdScreenActivities.ContactsListActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { /*if (BuildConfig.DEBUG) { Utils.enableStrictMode();//from w ww . j a v a 2s .c o m }*/ super.onCreate(savedInstanceState); // Set main content view. On smaller screen devices this is a single pane view with one // fragment. One larger screen devices this is a two pane view with two fragments. setContentView(R.layout.activity_contacts_main); // Check if this activity instance has been triggered as a result of a search query. This // will only happen on pre-HC OS versions as from HC onward search is carried out using // an ActionBar SearchView which carries out the search in-line without loading a new // Activity. if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) { // Fetch query from intent and notify the fragment that it should display search // results instead of all contacts. String searchQuery = getIntent().getStringExtra(SearchManager.QUERY); ContactsListFragment mContactsListFragment = (ContactsListFragment) getSupportFragmentManager() .findFragmentById(R.id.contact_list); // This flag notes that the Activity is doing a search, and so the result will be // search results rather than all contacts. This prevents the Activity and Fragment // from trying to a search on search results. isSearchResultView = true; mContactsListFragment.setSearchQuery(searchQuery); // Set special title for search results String title = getString(R.string.contacts_list_search_results_title, searchQuery); setTitle(title); } memory = new Bundle(); if (savedInstanceState == null) { Bundle extras = getIntent().getExtras(); if (extras != null) { for (String layoutElement : layoutElements) { if (extras.get(layoutElement) != null) { if (layoutElement.equals("Person")) { Bundle mp = null; mp = extras.getBundle("Person"); Log.i("Memory", "Got entry from previous activity: " + mp.keySet().toArray()[0].toString() + " " + mp.get(mp.keySet().toArray()[0].toString()).toString()); memory.putBundle("Person", mp); } else if (layoutElement.equals("Point")) { Bundle mp = null; mp = extras.getBundle("Point"); Log.i("Memory", "Got entry from previous activity: " + mp.keySet().toArray()[0].toString() + " " + mp.get(mp.keySet().toArray()[0].toString()).toString()); memory.putBundle("Point", mp); } else { memory.putString(layoutElement, extras.get(layoutElement).toString()); Log.i("Memory", "Got entry from prevoius activity: " + layoutElement + ": " + extras.get(layoutElement).toString()); } } } } } }
From source file:com.winginno.charitynow.GcmIntentService.java
private void sendNotification(Bundle extras) { Log.i(TAG, "GcmIntentService.sendNotification"); mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent openUrlIntent = new Intent(Intent.ACTION_VIEW); openUrlIntent.setData(Uri.parse((String) extras.get(PROPERTY_LINK))); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, openUrlIntent, 0); String title = (String) extras.get(PROPERTY_TITLE); String msg = (String) extras.get(PROPERTY_DESCRIPTION); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_noti) .setContentTitle(title).setContentText(msg).setAutoCancel(true); Date now = new Date(); int notiId = (int) (now.getTime() % 1000000); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(notiId, mBuilder.build()); }
From source file:com.lingeringsocket.mobflare.RpcCoordinator.java
String createFlare(String name, Bundle props) throws Exception { HttpPut httpPut = new HttpPut(generateFlareUri(name)); try {// ww w .j a va 2 s . c o m JSONObject jsonObj = new JSONObject(); for (String key : props.keySet()) { jsonObj.put(key, props.get(key)); } httpPut.setEntity(new StringEntity(jsonObj.toString())); HttpResponse httpResponse = execute(httpPut); if (httpResponse.getStatusLine().getStatusCode() == 409) { errId = R.string.duplicate_flare_name; throw new RuntimeException("Flare name already in use"); } String json = readInputStream(httpResponse.getEntity().getContent()); JSONTokener tokener = new JSONTokener(json); jsonObj = new JSONObject(tokener); return jsonObj.getString("name"); } catch (Exception ex) { Log.e(LOGTAG, "HTTP PUT failed", ex); throw ex; } }
From source file:com.jonathanhester.friendwatcher.FriendWatcherActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); Bundle extras = intent.getExtras(); if (extras != null) { String type = (String) extras.get("type"); if (type != null) showUnfriended();/*from w w w . j a va 2 s. c o m*/ } }
From source file:com.facebook.internal.BoltsMeasurementEventListener.java
@Override public void onReceive(Context context, Intent intent) { AppEventsLogger appEventsLogger = AppEventsLogger.newLogger(context); String eventName = BOLTS_MEASUREMENT_EVENT_PREFIX + intent.getStringExtra(MEASUREMENT_EVENT_NAME_KEY); Bundle eventArgs = intent.getBundleExtra(MEASUREMENT_EVENT_ARGS_KEY); Bundle logData = new Bundle(); for (String key : eventArgs.keySet()) { String safeKey = key.replaceAll("[^0-9a-zA-Z _-]", "-").replaceAll("^[ -]*", "").replaceAll("[ -]*$", ""); logData.putString(safeKey, (String) eventArgs.get(key)); }//from ww w . ja v a 2 s.c o m appEventsLogger.logEvent(eventName, logData); }
From source file:com.annuletconsulting.homecommand.node.MainFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { speechRecognizer = SpeechRecognizer.createSpeechRecognizer(getActivity()); speechRecognizer.setRecognitionListener(new RecognitionListener() { @Override// w ww . ja v a 2 s. c o m public void onReadyForSpeech(Bundle params) { for (String key : params.keySet()) Log.d(TAG, (String) params.get(key)); } @Override public void onBeginningOfSpeech() { Log.d(TAG, "Begin"); ignore = false; } @Override public void onRmsChanged(float rmsdB) { // Log.d(TAG, "Rms changed: "+rmsdB); } @Override public void onBufferReceived(byte[] buffer) { Log.d(TAG, "Buffer Received: " + buffer.toString()); } @Override public void onEndOfSpeech() { Log.d(TAG, "Endofspeech()"); } @Override public void onError(int error) { Log.d(TAG, "error: " + error); } @Override public void onResults(Bundle results) { Log.d(TAG, "onResults()"); for (String key : results.keySet()) { Log.d(TAG, key + ": " + results.get(key).toString()); // Iterator<String> it = ((ArrayList<String>) // results.get(key)).listIterator(); // while (it.hasNext()) // Log.d(TAG, it.next()); } if (!ignore) sendToServer(results.getStringArrayList(RESULTS_KEY).get(0)); } @Override public void onPartialResults(Bundle partialResults) { // Log.d(TAG, "onPartialResults()"); // String firstWord = partialResults.getStringArrayList(RESULTS_KEY).get(0).split(" ")[0]; // Log.d(TAG, firstWord); // if (firstWord.length() > 0 && !firstWord.equalsIgnoreCase("computer") && !firstWord.equalsIgnoreCase("android")) { // Log.d(TAG, "Killing this Recognition."); // ignore = true; // stopRecognizing(); // startListening(); // } } @Override public void onEvent(int eventType, Bundle params) { Log.d(TAG, "onEvent() type: " + eventType); for (String key : params.keySet()) Log.d(TAG, (String) params.get(key)); } }); View v = inflater.inflate(R.layout.main_fragment, null); button = (Button) v.findViewById(R.id.listen_button); button.setBackgroundResource(R.drawable.stopped); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { toggleListenMode(); } }); instance = this; return v; }