List of usage examples for android.app Activity getComponentName
public ComponentName getComponentName()
From source file:com.jaspersoft.android.jaspermobile.test.acceptance.viewer.WebViewInjector.java
@Override public void onActivityLifecycleChanged(Activity activity, Stage stage) { ComponentName targetComponentName = new ComponentName(activity, mClass.getName()); ComponentName currentComponentName = activity.getComponentName(); if (!currentComponentName.equals(targetComponentName)) return;/*from w w w.j a v a 2s. c o m*/ switch (stage) { case RESUMED: // As soon as, we are trying to register inject of idle resource during on Resume. // We need to do this only first time. And yes, I know it is dirty. Any suggestions welcomed :) if (!mInjected) { FragmentActivity htmlViewerActivity = (FragmentActivity) activity; WebViewFragment fragment = (WebViewFragment) htmlViewerActivity.getSupportFragmentManager() .findFragmentByTag(WebViewFragment.TAG); ViewGroup holder = (ViewGroup) fragment.getView().findViewById(R.id.webViewPlaceholder); // We need to wait for the activity to be created before getting a reference // to the webview JSWebView webView = (JSWebView) holder.getChildAt(0); mWebViewIdlingResource.inject(webView); mInjected = true; } break; case STOPPED: // Clean up reference if (activity.isFinishing()) mWebViewIdlingResource.clear(); break; default: // NOP } }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Sets up the search view in the action bar *///from ww w . ja v a 2 s .co m public static void setupSearch(Activity activity, Menu menu) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); final MenuItem searchMenu = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenu); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); // Close the keyboard and SearchView at same time when the back button is pressed searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View view, boolean queryTextFocused) { if (!queryTextFocused) { MenuItemCompat.collapseActionView(searchMenu); } } }); } }
From source file:com.google.android.apps.mytracks.util.Api11Adapter.java
@Override public void configureSearchWidget(Activity activity, final MenuItem menuItem) { SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); SearchView searchView = (SearchView) menuItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); searchView.setQueryRefinementEnabled(true); }
From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java
/** * Invoked when the options menu is created. Creates our own options menu * from the corresponding xml.//from w ww . jav a 2s. co m * * @param menu the options menu */ @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) { super.onCreateOptionsMenu(menu, menuInflater); Activity activity = getActivity(); // Get the SearchView and set the searchable configuration SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE); this.searchItem = menu.findItem(R.id.search); // OnActionExpandListener not supported prior API 14 if (AndroidUtils.hasAPI(14)) { searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() { @Override public boolean onMenuItemActionCollapse(MenuItem item) { filterContactList(""); return true; // Return true to collapse action view } public boolean onMenuItemActionExpand(MenuItem item) { return true; // Return true to expand action view } }); } if (AndroidUtils.hasAPI(11)) { SearchView searchView = (SearchView) searchItem.getActionView(); searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName())); int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); TextView textView = (TextView) searchView.findViewById(id); textView.setTextColor(getResources().getColor(R.color.white)); textView.setHintTextColor(getResources().getColor(R.color.white)); bindSearchListener(); } }