List of usage examples for android.content Intent getDataString
public @Nullable String getDataString()
From source file:org.openintents.shopping.ui.ShoppingActivity.java
/** * Obtain items from extras./*from w w w. j av a 2 s .c o m*/ */ private void getShoppingExtras(final Intent intent) { mExtraItems = intent.getExtras().getStringArrayList(ShoppingListIntents.EXTRA_STRING_ARRAYLIST_SHOPPING); mExtraQuantities = intent.getExtras() .getStringArrayList(ShoppingListIntents.EXTRA_STRING_ARRAYLIST_QUANTITY); mExtraPrices = intent.getExtras().getStringArrayList(ShoppingListIntents.EXTRA_STRING_ARRAYLIST_PRICE); mExtraBarcodes = intent.getExtras().getStringArrayList(ShoppingListIntents.EXTRA_STRING_ARRAYLIST_BARCODE); mExtraListUri = null; if ((intent.getDataString() != null) && (intent.getDataString().startsWith(ShoppingContract.Lists.CONTENT_URI.toString()))) { // We received a valid shopping list URI. // Set current list to received list: mExtraListUri = intent.getData(); if (debug) { Log.d(TAG, "Received extras for " + mExtraListUri.toString()); } } }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
public void handleMediaReceiver() { storageReceiver = new BroadcastReceiver() { @Override//ww w.j a va2 s.co m public void onReceive(Context context, Intent intent) { String action = intent.getAction(); String data = intent.getDataString(); final String path = data.replace("file://", ""); if (action.equals(Intent.ACTION_MEDIA_MOUNTED)) handleRefreshMedia(path, true, 10); else refreshBookmarks(); } }; IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_MOUNTED); filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); filter.addAction(Intent.ACTION_MEDIA_SCANNER_STARTED); filter.addAction(Intent.ACTION_MEDIA_SCANNER_FINISHED); filter.addAction(Intent.ACTION_MEDIA_EJECT); filter.addDataScheme("file"); registerReceiver(storageReceiver, filter); ContentObserver mDbObserver = new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { //rebake(false, ImageManager.isMediaScannerScanning( // getContentResolver())); } }; getContentResolver().registerContentObserver(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, true, mDbObserver); }
From source file:org.openintents.shopping.ui.ShoppingActivity.java
/** * This method is called when the sending activity has finished, with the * result it supplied.//from www. ja v a2 s .c o m * * @param requestCode The original request code as given to startActivity(). * @param resultCode From sending activity as per setResult(). * @param data From sending activity as per setResult(). * @see android.app.Activity#onActivityResult(int, int, android.content.Intent) */ @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (debug) { Log.i(TAG, "ShoppingView: onActivityResult. "); } if (requestCode == SUBACTIVITY_LIST_SHARE_SETTINGS) { if (debug) { Log.i(TAG, "SUBACTIVITY_LIST_SHARE_SETTINGS"); } if (resultCode == RESULT_CANCELED) { // Don't do anything. if (debug) { Log.i(TAG, "RESULT_CANCELED"); } } else { // Broadcast the intent if (debug) { Log.i(TAG, "Broadcast intent."); } // TODO ??? /* * Uri uri = Uri.parse(data); */ Uri uri = Uri.parse(data.getDataString()); if (!mListUri.equals(uri)) { Log.e(TAG, "Unexpected uri returned: Should be " + mListUri + " but was " + uri); return; } // TODO ??? Bundle extras = data.getExtras(); String sharename = extras.getString(ShoppingContract.Lists.SHARE_NAME); String contacts = extras.getString(ShoppingContract.Lists.SHARE_CONTACTS); if (debug) { Log.i(TAG, "Received bundle: sharename: " + sharename + ", contacts: " + contacts); } // Here we also send the current content of the list // to all recipients. // This could probably be optimized - by sending // content only to the new recipients, as the // old ones should be in sync already. // First delete all items in list /* * mCursorItems.moveToPosition(-1); while * (mCursorItems.moveToNext()) { String itemName = mCursorItems * .getString(mStringItemsITEMNAME); Long status = * mCursorItems.getLong(mStringItemsSTATUS); Log.i(TAG, * "Update shared item. " + " recipients: " + contacts + * ", shareName: " + sharename + ", item: " + itemName); // TODO * ??? /* mGTalkSender.sendItemUpdate(contacts, sharename, * itemName, itemName, status, status); / } */ } } else if (REQUEST_CODE_CATEGORY_ALTERNATIVE == requestCode) { if (debug) { Log.d(TAG, "result received"); } if (RESULT_OK == resultCode) { if (debug) { Log.d(TAG, "result OK"); } // Check if any results have been returned: /* * if ((data.getDataString() != null) && * (data.getDataString().startsWith * (Shopping.Lists.CONTENT_URI.toString()))) { // We received a * valid shopping list URI. * * // Set current list to received list: mListUri = * data.getData(); intent.setData(mListUri); } */ if (data.getExtras() != null) { if (debug) { Log.d(TAG, "extras received"); } getShoppingExtras(data); } } } else if (REQUEST_PICK_LIST == requestCode) { if (debug) { Log.d(TAG, "result received"); } if (RESULT_OK == resultCode) { int position = mMoveItemPosition; if (mMoveItemPosition >= 0) { moveItem(position, Integer.parseInt(data.getData().getLastPathSegment())); } } mMoveItemPosition = -1; } }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
private void addTorrentByIntent(Intent intent) { // Log.d("Debug", "addTorrentByIntent invoked"); urlTorrent = intent.getDataString(); ///*from w w w .ja v a 2 s. c o m*/ // Log.d("Debug", "urlTorrent: "+ urlTorrent); // Log.d("Debug", "intent: " + intent.toString()); if (urlTorrent != null && urlTorrent.length() != 0) { // Check dangerous permissions checkDangerousPermissions(); } try { if (intent.getStringExtra("from").equals("NotifierService")) { saveLastState("completed"); setSelectionAndTitle("completed"); refresh("completed", currentLabel); } } catch (NullPointerException npe) { } }
From source file:org.mozilla.gecko.GeckoApp.java
@Override protected void onNewIntent(Intent intent) { Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onNewIntent"); if (checkLaunchState(LaunchState.GeckoExiting)) { // We're exiting and shouldn't try to do anything else just incase // we're hung for some reason we'll force the process to exit System.exit(0);//from w w w .j a v a 2 s . c o m return; } if (checkLaunchState(LaunchState.Launched)) { Uri data = intent.getData(); Bundle bundle = intent.getExtras(); // if the intent has data (i.e. a URI to be opened) and the scheme // is either http, we'll prefetch it, which means warming // up the radio and DNS cache by connecting and parsing the redirect // if the return code is between 300 and 400 if (data != null && "http".equals(data.getScheme()) && (bundle == null || bundle.getInt("prefetched", 0) != 1) && isHostOnPrefetchWhitelist(data.getHost())) { GeckoAppShell.getHandler().post(new RedirectorRunnable(intent)); return; } } final String action = intent.getAction(); if (ACTION_DEBUG.equals(action) && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) { mMainHandler.postDelayed(new Runnable() { public void run() { Log.i(LOGTAG, "Launching from debug intent after 5s wait"); setLaunchState(LaunchState.Launching); sGeckoThread.start(); } }, 1000 * 5 /* 5 seconds */); Log.i(LOGTAG, "Intent : ACTION_DEBUG - waiting 5s before launching"); return; } if (checkLaunchState(LaunchState.WaitForDebugger) || intent == getIntent()) return; if (Intent.ACTION_MAIN.equals(action)) { Log.i(LOGTAG, "Intent : ACTION_MAIN"); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent("")); } else if (ACTION_LOAD.equals(action)) { String uri = intent.getDataString(); loadUrl(uri, AwesomeBar.Type.EDIT); Log.i(LOGTAG, "onNewIntent: " + uri); } else if (Intent.ACTION_VIEW.equals(action)) { String uri = intent.getDataString(); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri)); Log.i(LOGTAG, "onNewIntent: " + uri); } else if (ACTION_WEBAPP.equals(action)) { String uri = getURIFromIntent(intent); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri)); Log.i(LOGTAG, "Intent : WEBAPP - " + uri); } else if (ACTION_BOOKMARK.equals(action)) { String uri = getURIFromIntent(intent); GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri)); Log.i(LOGTAG, "Intent : BOOKMARK - " + uri); } }
From source file:org.mozilla.gecko.BrowserApp.java
@Override protected void onNewIntent(Intent intent) { String action = intent.getAction(); final boolean isViewAction = Intent.ACTION_VIEW.equals(action); final boolean isBookmarkAction = GeckoApp.ACTION_HOMESCREEN_SHORTCUT.equals(action); final boolean isTabQueueAction = TabQueueHelper.LOAD_URLS_ACTION.equals(action); if (mInitialized && (isViewAction || isBookmarkAction)) { // Dismiss editing mode if the user is loading a URL from an external app. mBrowserToolbar.cancelEdit();/*from w w w .j a v a 2 s .c o m*/ // Hide firstrun-pane if the user is loading a URL from an external app. hideFirstrunPager(); if (isBookmarkAction) { // GeckoApp.ACTION_HOMESCREEN_SHORTCUT means we're opening a bookmark that // was added to Android's homescreen. Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.HOMESCREEN); } } showTabQueuePromptIfApplicable(intent); super.onNewIntent(intent); if (AppConstants.MOZ_ANDROID_BEAM && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action)) { String uri = intent.getDataString(); GeckoAppShell.sendEventToGecko(GeckoEvent.createURILoadEvent(uri)); } // Only solicit feedback when the app has been launched from the icon shortcut. if (GuestSession.NOTIFICATION_INTENT.equals(action)) { GuestSession.handleIntent(this, intent); } // If the user has clicked the tab queue notification then load the tabs. if (AppConstants.NIGHTLY_BUILD && AppConstants.MOZ_ANDROID_TAB_QUEUE && mInitialized && isTabQueueAction) { Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.NOTIFICATION, "tabqueue"); ThreadUtils.postToBackgroundThread(new Runnable() { @Override public void run() { openQueuedTabs(); } }); } if (!mInitialized || !Intent.ACTION_MAIN.equals(action)) { return; } // Check to see how many times the app has been launched. final String keyName = getPackageName() + ".feedback_launch_count"; final StrictMode.ThreadPolicy savedPolicy = StrictMode.allowThreadDiskReads(); // Faster on main thread with an async apply(). try { SharedPreferences settings = getPreferences(Activity.MODE_PRIVATE); int launchCount = settings.getInt(keyName, 0); if (launchCount < FEEDBACK_LAUNCH_COUNT) { // Increment the launch count and store the new value. launchCount++; settings.edit().putInt(keyName, launchCount).apply(); // If we've reached our magic number, show the feedback page. if (launchCount == FEEDBACK_LAUNCH_COUNT) { GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Feedback:Show", null)); } } } finally { StrictMode.setThreadPolicy(savedPolicy); } }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
/** * Returns true if the Intent was "Handled" * @param intent Input Intent//w w w. j a va 2 s. c o m */ public boolean handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { OpenPath searchIn = new OpenFile("/"); Bundle bundle = intent.getBundleExtra(SearchManager.APP_DATA); if (bundle != null && bundle.containsKey("path")) try { searchIn = FileManager.getOpenCache(bundle.getString("path"), false, null); } catch (IOException e) { searchIn = new OpenFile(bundle.getString("path")); } String query = intent.getStringExtra(SearchManager.QUERY); Logger.LogDebug("ACTION_SEARCH for \"" + query + "\" in " + searchIn); SearchResultsFragment srf = SearchResultsFragment.getInstance(searchIn, query); if (mViewPagerEnabled && mViewPagerAdapter != null) { mViewPagerAdapter.add(srf); setViewPageAdapter(mViewPagerAdapter, true); setCurrentItem(mViewPagerAdapter.getCount() - 1, true); } else { getSupportFragmentManager().beginTransaction().replace(R.id.content_frag, srf).commit(); } } else if ((Intent.ACTION_VIEW.equals(intent.getAction()) || Intent.ACTION_EDIT.equals(intent.getAction())) && intent.getData() != null) { OpenPath path = FileManager.getOpenCache(intent.getDataString(), this); if (editFile(path)) return true; } else if (intent.hasExtra("state")) { Bundle state = intent.getBundleExtra("state"); onRestoreInstanceState(state); } return false; }
From source file:org.openintents.shopping.ui.ShoppingActivity.java
/** * Called when the activity is first created. *///from ww w. j av a2s. c o m @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); if (debug) { Log.d(TAG, "Shopping list onCreate()"); } mSortOrder = PreferenceActivity.getShoppingListSortOrderFromPrefs(this); mDistribution.setFirst(MENU_DISTRIBUTION_START, DIALOG_DISTRIBUTION_START); // Check whether EULA has been accepted // or information about new version can be presented. if (false && mDistribution.showEulaOrNewVersion()) { return; } setContentView(R.layout.activity_shopping); // mEditItemPosition = -1; // Automatic requeries (once a second) mUpdateInterval = 2000; mUpdating = false; // General Uris: mListUri = ShoppingContract.Lists.CONTENT_URI; mItemUri = ShoppingContract.Items.CONTENT_URI; mListItemUri = ShoppingContract.Items.CONTENT_URI; int defaultShoppingList = getLastUsedListFromPrefs(); // Handle the calling intent final Intent intent = getIntent(); final String type = intent.resolveType(this); final String action = intent.getAction(); if (action == null) { // Main action mState = STATE_MAIN; mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList); intent.setData(mListUri); } else if (Intent.ACTION_MAIN.equals(action)) { // Main action mState = STATE_MAIN; mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList); intent.setData(mListUri); } else if (Intent.ACTION_VIEW.equals(action)) { mState = STATE_VIEW_LIST; setListUriFromIntent(intent.getData(), type); } else if (Intent.ACTION_INSERT.equals(action)) { mState = STATE_VIEW_LIST; setListUriFromIntent(intent.getData(), type); } else if (Intent.ACTION_PICK.equals(action)) { mState = STATE_PICK_ITEM; mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList); } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState = STATE_GET_CONTENT_ITEM; mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList); } else if (GeneralIntents.ACTION_INSERT_FROM_EXTRAS.equals(action)) { if (ShoppingListIntents.TYPE_STRING_ARRAYLIST_SHOPPING.equals(type)) { /* * Need to insert new items from a string array in the intent * extras Use main action but add an item to the options menu * for adding extra items */ getShoppingExtras(intent); mState = STATE_MAIN; mListUri = Uri.withAppendedPath(ShoppingContract.Lists.CONTENT_URI, "" + defaultShoppingList); intent.setData(mListUri); } else if (intent.getDataString().startsWith(ShoppingContract.Lists.CONTENT_URI.toString())) { // Somewhat quick fix to pass data from ShoppingListsActivity to // this activity. // We received a valid shopping list URI: mListUri = intent.getData(); getShoppingExtras(intent); mState = STATE_MAIN; intent.setData(mListUri); } } else { // Unknown action. Log.e(TAG, "Shopping: Unknown action, exiting"); finish(); return; } // hook up all buttons, lists, edit text: createView(); // populate the lists fillListFilter(); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); // Get last part of URI: int selectList; try { selectList = Integer.parseInt(mListUri.getLastPathSegment()); } catch (NumberFormatException e) { selectList = defaultShoppingList; } // select the default shopping list at the beginning: setSelectedListId(selectList); if (icicle != null) { String prevText = icicle.getString(ORIGINAL_ITEM); if (prevText != null) { mEditText.setTextKeepState(prevText); } // mTextEntryMenu = icicle.getInt(BUNDLE_TEXT_ENTRY_MENU); // mEditItemPosition = icicle.getInt(BUNDLE_CURSOR_ITEMS_POSITION); mItemUri = Uri.parse(icicle.getString(BUNDLE_ITEM_URI)); List<String> pathSegs = mItemUri.getPathSegments(); int num = pathSegs.size(); mListItemUri = Uri.withAppendedPath(mListUri, pathSegs.get(num - 1)); if (icicle.containsKey(BUNDLE_RELATION_URI)) { mRelationUri = Uri.parse(icicle.getString(BUNDLE_RELATION_URI)); } mItemsView.mMode = icicle.getInt(BUNDLE_MODE); mItemsView.mModeBeforeSearch = icicle.getInt(BUNDLE_MODE_BEFORE_SEARCH); } // set focus to the edit line: mEditText.requestFocus(); // TODO remove initFromPreferences from onCreate // we need it in resume to update after settings have changed initFromPreferences(); // now update title and fill all items onModeChanged(); mItemsView.setActionBarListener(this); mItemsView.setUndoListener(this); if ("myo".equals(BuildConfig.FLAVOR)) { try { Class myoToggleBoughtInputMethod = Class .forName("org.openintents.shopping.ui.MyoToggleBoughtInputMethod"); Constructor constructor = myoToggleBoughtInputMethod .getConstructor(new Class[] { ShoppingActivity.class, mItemsView.getClass() }); toggleBoughtInputMethod = (ToggleBoughtInputMethod) constructor .newInstance(new Object[] { this, mItemsView }); } catch (ClassNotFoundException e) { } catch (NoSuchMethodException e) { } catch (InvocationTargetException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } } }
From source file:org.mozilla.gecko.BrowserApp.java
@Override public void onCreate(Bundle savedInstanceState) { final Intent intent = getIntent(); // Note that we're calling GeckoProfile.get *before GeckoApp.onCreate*. // This means we're reliant on the logic in GeckoProfile to correctly // look up our launch intent (via BrowserApp's Activity-ness) and pull // out the arguments. Be careful if you change that! final GeckoProfile p = GeckoProfile.get(this); if (p != null && !p.inGuestMode()) { // This is *only* valid because we never want to use the guest mode // profile concurrently with a normal profile -- no syncing to it, // no dual-profile usage, nothing. BrowserApp startup with a conventional // GeckoProfile will cause the guest profile to be deleted. GeckoProfile.maybeCleanupGuestProfile(this); }// w w w .j a v a2 s .c o m // This has to be prepared prior to calling GeckoApp.onCreate, because // widget code and BrowserToolbar need it, and they're created by the // layout, which GeckoApp takes care of. ((GeckoApplication) getApplication()).prepareLightweightTheme(); super.onCreate(savedInstanceState); final Context appContext = ((GeckoApplication) getApplication()).getContext(); SharedPreferences prefs = GeckoSharedPrefs.forProfile(appContext); // TODO: Prevent if in Guest Mode? if (AppConstants.MOZ_ANDROID_GCM_PUSH) { this.gcmBridge = new GCM(AppConstants.MOZ_ANDROID_GCM_SENDERID); try { this.gcmBridge.onCreate(appContext, getActivity(), savedInstanceState); // A thread has been spawned to put the push endpoint into the preferences. } catch (IOException x) { // could not instantiate the GCM bridge, so fail. Logger.info(LOGTAG, "Google Play not present or available. GCM bridge unavailable."); this.gcmBridge = null; } catch (BridgeException x) { // Some other error caused the bridge to fail. Logger.error(LOGTAG, "Could not create the GCM bridge.", x); this.gcmBridge = null; } /* At this point, we have a GCM endpoint registered with the Push Service, but we need the user to log in so that we can associate the URL and user within the Device Manager. See */ } mBrowserChrome = (ViewGroup) findViewById(R.id.browser_chrome); mActionBarFlipper = (ViewFlipper) findViewById(R.id.browser_actionbar); mActionBar = (ActionModeCompatView) findViewById(R.id.actionbar); mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar); mProgressView = (ToolbarProgressView) findViewById(R.id.progress); mBrowserToolbar.setProgressBar(mProgressView); // Initialize Tab History Controller. tabHistoryController = new TabHistoryController(new OnShowTabHistory() { @Override public void onShowHistory(final List<TabHistoryPage> historyPageList, final int toIndex) { runOnUiThread(new Runnable() { @Override public void run() { final TabHistoryFragment fragment = TabHistoryFragment.newInstance(historyPageList, toIndex); final FragmentManager fragmentManager = getSupportFragmentManager(); GeckoAppShell.vibrateOnHapticFeedbackEnabled( getResources().getIntArray(R.array.long_press_vibrate_msec)); fragment.show(R.id.tab_history_panel, fragmentManager.beginTransaction(), TAB_HISTORY_FRAGMENT_TAG); } }); } }); mBrowserToolbar.setTabHistoryController(tabHistoryController); final String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { // Show the target URL immediately in the toolbar. mBrowserToolbar.setTitle(intent.getDataString()); showTabQueuePromptIfApplicable(intent); } else if (GuestSession.NOTIFICATION_INTENT.equals(action)) { GuestSession.handleIntent(this, intent); } else if (TabQueueHelper.LOAD_URLS_ACTION.equals(action)) { Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.NOTIFICATION, "tabqueue"); } if (HardwareUtils.isTablet()) { mTabStrip = (Refreshable) (((ViewStub) findViewById(R.id.new_tablet_tab_strip)).inflate()); } ((GeckoApp.MainLayout) mMainLayout).setTouchEventInterceptor(new HideOnTouchListener()); ((GeckoApp.MainLayout) mMainLayout).setMotionEventInterceptor(new MotionEventInterceptor() { @Override public boolean onInterceptMotionEvent(View view, MotionEvent event) { // If we get a gamepad panning MotionEvent while the focus is not on the layerview, // put the focus on the layerview and carry on if (mLayerView != null && !mLayerView.hasFocus() && GamepadUtils.isPanningControl(event)) { if (mHomePager == null) { return false; } if (isHomePagerVisible()) { mLayerView.requestFocus(); } else { mHomePager.requestFocus(); } } return false; } }); mHomePagerContainer = (ViewGroup) findViewById(R.id.home_pager_container); mBrowserSearchContainer = findViewById(R.id.search_container); mBrowserSearch = (BrowserSearch) getSupportFragmentManager().findFragmentByTag(BROWSER_SEARCH_TAG); if (mBrowserSearch == null) { mBrowserSearch = BrowserSearch.newInstance(); mBrowserSearch.setUserVisibleHint(false); } setBrowserToolbarListeners(); mFindInPageBar = (FindInPageBar) findViewById(R.id.find_in_page); mMediaCastingBar = (MediaCastingBar) findViewById(R.id.media_casting); EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this, "Menu:Open", "Menu:Update", "LightweightTheme:Update", "Search:Keyword", "Prompt:ShowTop", "Accounts:Exist"); EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener) this, "Accounts:Create", "Accounts:CreateFirefoxAccountFromJSON", "CharEncoding:Data", "CharEncoding:State", "Favicon:CacheLoad", "Feedback:LastUrl", "Feedback:MaybeLater", "Feedback:OpenPlayStore", "Menu:Add", "Menu:Remove", "Reader:Share", "Sanitize:ClearHistory", "Sanitize:ClearSyncedTabs", "Settings:Show", "Telemetry:Gather", "Updater:Launch"); Distribution distribution = Distribution.init(this); // Init suggested sites engine in BrowserDB. final SuggestedSites suggestedSites = new SuggestedSites(appContext, distribution); final BrowserDB db = getProfile().getDB(); db.setSuggestedSites(suggestedSites); JavaAddonManager.getInstance().init(appContext); mSharedPreferencesHelper = new SharedPreferencesHelper(appContext); mOrderedBroadcastHelper = new OrderedBroadcastHelper(appContext); mBrowserHealthReporter = new BrowserHealthReporter(); mReadingListHelper = new ReadingListHelper(appContext, getProfile(), this); if (AppConstants.MOZ_ANDROID_BEAM) { NfcAdapter nfc = NfcAdapter.getDefaultAdapter(this); if (nfc != null) { nfc.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() { @Override public NdefMessage createNdefMessage(NfcEvent event) { Tab tab = Tabs.getInstance().getSelectedTab(); if (tab == null || tab.isPrivate()) { return null; } return new NdefMessage(new NdefRecord[] { NdefRecord.createUri(tab.getURL()) }); } }, this); } } if (savedInstanceState != null) { mDynamicToolbar.onRestoreInstanceState(savedInstanceState); mHomePagerContainer.setPadding(0, savedInstanceState.getInt(STATE_ABOUT_HOME_TOP_PADDING), 0, 0); } mDynamicToolbar.setEnabledChangedListener(new DynamicToolbar.OnEnabledChangedListener() { @Override public void onEnabledChanged(boolean enabled) { setDynamicToolbarEnabled(enabled); } }); mDragHelper = new DragHelper(); mRootLayout.setDraggableCallback(mDragHelper); // Set the maximum bits-per-pixel the favicon system cares about. IconDirectoryEntry.setMaxBPP(GeckoAppShell.getScreenDepth()); if (ZOOMED_VIEW_ENABLED) { ViewStub stub = (ViewStub) findViewById(R.id.zoomed_view_stub); mZoomedView = (ZoomedView) stub.inflate(); } }