List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.jtechme.apphub.AppDetailsData.java
@Override protected void onCreate(Bundle savedInstanceState) { fdroidApp = (FDroidApp) getApplication(); fdroidApp.applyTheme(this); super.onCreate(savedInstanceState); // Must be called *after* super.onCreate(), as that is where the action bar // compat implementation is assigned in the ActionBarActivity base class. supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); Intent intent = getIntent(); if (intent.hasExtra(EXTRA_FROM)) { setTitle(intent.getStringExtra(EXTRA_FROM)); }/*from w w w.ja v a 2s. c om*/ mPm = getPackageManager(); installer = Installer.getActivityInstaller(this, mPm, myInstallerCallback); // Get the preferences we're going to use in this Activity... ConfigurationChangeHelper previousData = (ConfigurationChangeHelper) getLastCustomNonConfigurationInstance(); if (previousData != null) { Utils.debugLog(TAG, "Recreating view after configuration change."); downloadHandler = previousData.downloader; if (downloadHandler != null) { Utils.debugLog(TAG, "Download was in progress before the configuration change, so we will start to listen to its events again."); } app = previousData.app; setApp(app); } else { if (!reset(getPackageNameFromIntent(intent))) { finish(); return; } } // Set up the list... adapter = new ApkListAdapter(this, app); // Wait until all other intialization before doing this, because it will create the // fragments, which rely on data from the activity that is set earlier in this method. setContentView(R.layout.app_details); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Check for the presence of a view which only exists in the landscape view. // This seems to be the preferred way to interrogate the view, rather than // to check the orientation. I guess this is because views can be dynamically // chosen based on more than just orientation (e.g. large screen sizes). View onlyInLandscape = findViewById(R.id.app_summary_container); AppDetailsListFragment listFragment = (AppDetailsListFragment) getSupportFragmentManager() .findFragmentById(R.id.fragment_app_list); if (onlyInLandscape == null) { listFragment.setupSummaryHeader(); } else { listFragment.removeSummaryHeader(); } localBroadcastManager = LocalBroadcastManager.getInstance(this); // Check if a download is running for this app if (AsyncDownloaderFromAndroid.isDownloading(this, app.packageName) >= 0) { // call install() to re-setup the listeners and downloaders // the AsyncDownloader will not restart the download since the download is running, // and thus the version we pass to install() is not important refreshHeader(); refreshApkList(); final Apk apkToInstall = ApkProvider.Helper.find(this, app.packageName, app.suggestedVercode); install(apkToInstall); } }
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
private void handleExport(final Intent data) { new AsyncTask<Object, Object, Throwable>() { @Override/* w w w.j a v a 2 s . c o m*/ protected Throwable doInBackground(Object... objects) { OutputStream out = null; try { Uri target = data.getData(); if (data.hasExtra("org.openintents.extra.DIR_PATH")) target = Uri.parse(target + "/netguard_" + new SimpleDateFormat("yyyyMMdd").format(new Date().getTime()) + ".xml"); Log.i(TAG, "Writing URI=" + target); out = getContentResolver().openOutputStream(target); xmlExport(out); return null; } catch (Throwable ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); return ex; } finally { if (out != null) try { out.close(); } catch (IOException ex) { Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); } } } @Override protected void onPostExecute(Throwable ex) { if (running) { if (ex == null) Toast.makeText(ActivitySettings.this, R.string.msg_completed, Toast.LENGTH_LONG).show(); else Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show(); } } }.execute(); }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // historyManager must be initialized here to update the history preference // historyManager = new HistoryManager(this); // historyManager.trimHistory(); // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't // want to open the camera driver and measure the screen size if we're going to show the help on // first launch. That led to bugs where the scanning rectangle was the wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;//from w w w .ja v a2 s . com lastResult = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION, true)) { // setRequestedOrientation(getCurrentOrientation()); // } else { // setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); // } setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); resetStatusView(); beepManager.updatePrefs(); // ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); // copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) // && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; sourceUrl = null; // scanFromWebPageManager = null; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); decodeHints = DecodeHintManager.parseDecodeHints(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } if (intent.hasExtra(Intents.Scan.CAMERA_ID)) { int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1); if (cameraId >= 0) { cameraManager.setManualCameraId(cameraId); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) { // Scan only products and send the result to mobile Product Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none specified). // If a return URL is specified, send the results there. Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(dataString); // scanFromWebPageManager = new ScanFromWebPageManager(inputUri); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); // Allow a sub-set of the hints to be specified by the caller. decodeHints = DecodeHintManager.parseDecodeHints(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); } }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
private void onSendAction(Intent intent, String resourcePath) { if (intent.hasExtra(Intent.EXTRA_STREAM)) { final Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); UpDownServiceHelper.upload(this, uri, resourcePath, false); }//from ww w .j a v a 2 s. c om }
From source file:com.ubuntuone.android.files.activity.FilesActivity.java
private void onSendMultipleAction(Intent intent, String resourcePath) { if (intent.hasExtra(Intent.EXTRA_STREAM)) { ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); for (Parcelable item : list) { Uri uri = (Uri) item;//from w w w . j av a 2s. c om UpDownServiceHelper.upload(this, uri, resourcePath, false); } } }
From source file:com.onegravity.contactpicker.core.ContactPickerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // check if all custom attributes are defined if (!checkTheming()) { finish();/* ww w. ja va 2 s. c o m*/ return; } /* * Check if we have the READ_CONTACTS permission, if not --> terminate. */ try { int pid = android.os.Process.myPid(); PackageManager pckMgr = getPackageManager(); int uid = pckMgr.getApplicationInfo(getComponentName().getPackageName(), PackageManager.GET_META_DATA).uid; enforcePermission(Manifest.permission.READ_CONTACTS, pid, uid, "Contact permission hasn't been granted to this app, terminating."); } catch (PackageManager.NameNotFoundException | SecurityException e) { Log.e(getClass().getSimpleName(), e.getMessage()); finish(); return; } mDefaultTitle = "Select Contacts"; mThemeResId = R.style.Theme_Light; Intent intent = getIntent(); if (savedInstanceState == null) { // /* // * Retrieve default title used if no contacts are selected. // */ // try { // PackageManager pkMgr = getPackageManager(); // ActivityInfo activityInfo = pkMgr.getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); // mDefaultTitle = activityInfo.loadLabel(pkMgr).toString(); // } // catch (PackageManager.NameNotFoundException ignore) { // mDefaultTitle = getTitle().toString(); // } if (intent.hasExtra(EXTRA_PRESELECTED_CONTACTS)) { Collection<Long> preselectedContacts = (Collection<Long>) intent .getSerializableExtra(EXTRA_PRESELECTED_CONTACTS); mSelectedContactIds.addAll(preselectedContacts); } if (intent.hasExtra(EXTRA_PRESELECTED_GROUPS)) { Collection<Long> preselectedGroups = (Collection<Long>) intent .getSerializableExtra(EXTRA_PRESELECTED_GROUPS); mSelectedGroupIds.addAll(preselectedGroups); } // mThemeResId = intent.getIntExtra(EXTRA_THEME, R.style.ContactPicker_Theme_Light); } else { // mDefaultTitle = savedInstanceState.getString("mDefaultTitle"); // // mThemeResId = savedInstanceState.getInt("mThemeResId"); // Retrieve selected contact and group ids. try { mSelectedContactIds = (HashSet<Long>) savedInstanceState.getSerializable(CONTACT_IDS); mSelectedGroupIds = (HashSet<Long>) savedInstanceState.getSerializable(GROUP_IDS); } catch (ClassCastException ignore) { } } /* * Retrieve ContactPictureType. */ String enumName = intent.getStringExtra(EXTRA_CONTACT_BADGE_TYPE); mBadgeType = ContactPictureType.lookup(enumName); /* * Retrieve SelectContactsLimit. */ mSelectContactsLimit = intent.getIntExtra(EXTRA_SELECT_CONTACTS_LIMIT, 0); /* * Retrieve ShowCheckAll. */ mShowCheckAll = mSelectContactsLimit > 0 ? false : intent.getBooleanExtra(EXTRA_SHOW_CHECK_ALL, true); /* * Retrieve OnlyWithPhoneNumbers. */ mOnlyWithPhoneNumbers = intent.getBooleanExtra(EXTRA_ONLY_CONTACTS_WITH_PHONE, false); /* * Retrieve LimitReachedMessage. */ String limitMsg = intent.getStringExtra(EXTRA_LIMIT_REACHED_MESSAGE); if (limitMsg != null) { mLimitReachedMessage = limitMsg; } else { mLimitReachedMessage = getString(R.string.cp_limit_reached, mSelectContactsLimit); } /* * Retrieve ContactDescription. */ enumName = intent.getStringExtra(EXTRA_CONTACT_DESCRIPTION); mDescription = ContactDescription.lookup(enumName); mDescriptionType = intent.getIntExtra(EXTRA_CONTACT_DESCRIPTION_TYPE, ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME); /* * Retrieve ContactSortOrder. */ enumName = intent.getStringExtra(EXTRA_CONTACT_SORT_ORDER); mSortOrder = ContactSortOrder.lookup(enumName); setTheme(mThemeResId); setContentView(R.layout.cp_contact_tab_layout); // initialize TabLayout TabLayout tabLayout = (TabLayout) findViewById(R.id.tabContent); tabLayout.setTabMode(TabLayout.MODE_FIXED); tabLayout.setTabGravity(TabLayout.GRAVITY_FILL); TabLayout.Tab tabContacts = tabLayout.newTab(); tabContacts.setText(R.string.cp_contact_tab_title); tabLayout.addTab(tabContacts); TabLayout.Tab tabGroups = tabLayout.newTab(); tabGroups.setText(R.string.cp_group_tab_title); tabLayout.addTab(tabGroups); // initialize ViewPager final ViewPager viewPager = (ViewPager) findViewById(R.id.tabPager); mAdapter = new PagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount(), mSortOrder, mBadgeType, mDescription, mDescriptionType); viewPager.setAdapter(mAdapter); viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() { @Override public void onTabSelected(TabLayout.Tab tab) { viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(TabLayout.Tab tab) { } @Override public void onTabReselected(TabLayout.Tab tab) { } }); getSupportActionBar().setDisplayHomeAsUpEnabled(true); }
From source file:com.master.metehan.filtereagle.ActivityMain.java
@Override protected void onActivityResult(int requestCode, int resultCode, final Intent data) { Log.i(TAG, "onActivityResult request=" + requestCode + " result=" + requestCode + " ok=" + (resultCode == RESULT_OK)); Util.logExtras(data);/*from w w w .ja v a 2 s .co m*/ if (requestCode == REQUEST_VPN) { // Handle VPN approval SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.edit().putBoolean("enabled", resultCode == RESULT_OK).apply(); if (resultCode == RESULT_OK) { ServiceSinkhole.start("prepared", this); checkDoze(); } } else if (requestCode == REQUEST_INVITE) { // Do nothing } else if (requestCode == REQUEST_LOGCAT) { // Send logcat by e-mail if (resultCode == RESULT_OK) { Uri target = data.getData(); if (data.hasExtra("org.openintents.extra.DIR_PATH")) target = Uri.parse(target + "/logcat.txt"); Log.i(TAG, "Export URI=" + target); Util.sendLogcat(target, this); } } else { Log.w(TAG, "Unknown activity result request=" + requestCode); super.onActivityResult(requestCode, resultCode, data); } }
From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java
@Override protected void onResume() { super.onResume(); // historyManager must be initialized here to update the history preference // historyManager = new HistoryManager(this); // historyManager.trimHistory(); // CameraManager must be initialized here, not in onCreate(). This is necessary because we don't // want to open the camera driver and measure the screen size if we're going to show the help on // first launch. That led to bugs where the scanning rectangle was the wrong size and partially // off screen. cameraManager = new CameraManager(getApplication()); viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view); viewfinderView.setCameraManager(cameraManager); resultView = findViewById(R.id.result_view); statusView = (TextView) findViewById(R.id.status_view); handler = null;/*from w w w. j a v a2 s . c o m*/ lastResult = null; SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getBoolean(PreferencesActivity.KEY_DISABLE_AUTO_ORIENTATION, true)) { //setRequestedOrientation(getCurrentOrientation()); } else { //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } resetStatusView(); beepManager.updatePrefs(); ambientLightManager.start(cameraManager); inactivityTimer.onResume(); Intent intent = getIntent(); copyToClipboard = prefs.getBoolean(PreferencesActivity.KEY_COPY_TO_CLIPBOARD, true) && (intent == null || intent.getBooleanExtra(Intents.Scan.SAVE_HISTORY, true)); source = IntentSource.NONE; sourceUrl = null; scanFromWebPageManager = null; decodeFormats = null; characterSet = null; if (intent != null) { String action = intent.getAction(); String dataString = intent.getDataString(); if (Intents.Scan.ACTION.equals(action)) { // Scan the formats the intent requested, and return the result to the calling activity. source = IntentSource.NATIVE_APP_INTENT; decodeFormats = DecodeFormatManager.parseDecodeFormats(intent); decodeHints = DecodeHintManager.parseDecodeHints(intent); if (intent.hasExtra(Intents.Scan.WIDTH) && intent.hasExtra(Intents.Scan.HEIGHT)) { int width = intent.getIntExtra(Intents.Scan.WIDTH, 0); int height = intent.getIntExtra(Intents.Scan.HEIGHT, 0); if (width > 0 && height > 0) { cameraManager.setManualFramingRect(width, height); } } if (intent.hasExtra(Intents.Scan.CAMERA_ID)) { int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1); if (cameraId >= 0) { cameraManager.setManualCameraId(cameraId); } } String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE); if (customPromptMessage != null) { statusView.setText(customPromptMessage); } } else if (dataString != null && dataString.contains("http://www.google") && dataString.contains("/m/products/scan")) { // Scan only products and send the result to mobile Product Search. source = IntentSource.PRODUCT_SEARCH_LINK; sourceUrl = dataString; decodeFormats = DecodeFormatManager.PRODUCT_FORMATS; } else if (isZXingURL(dataString)) { // Scan formats requested in query string (all formats if none specified). // If a return URL is specified, send the results there. Otherwise, handle it ourselves. source = IntentSource.ZXING_LINK; sourceUrl = dataString; Uri inputUri = Uri.parse(dataString); scanFromWebPageManager = new ScanFromWebPageManager(inputUri); decodeFormats = DecodeFormatManager.parseDecodeFormats(inputUri); // Allow a sub-set of the hints to be specified by the caller. decodeHints = DecodeHintManager.parseDecodeHints(inputUri); } characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET); } SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view); SurfaceHolder surfaceHolder = surfaceView.getHolder(); if (hasSurface) { // The activity was paused but not stopped, so the surface still exists. Therefore // surfaceCreated() won't be called, so init the camera here. initCamera(surfaceHolder); } else { // Install the callback and wait for surfaceCreated() to init the camera. surfaceHolder.addCallback(this); } }
From source file:com.mario22gmail.license.nfc_project.NavigationDrawerActivity.java
@Override protected void onNewIntent(Intent intent) { Log.i(nfcDebugTag, "Tag detected "); Toast.makeText(this, "Card detectat", Toast.LENGTH_SHORT).show(); isCardEmpty = true;//ww w .ja v a 2 s . c o m try { libInstance.filterIntent(intent, mCallback); // FragmentPinDialog fragment = new FragmentPinDialog(); // fragment.show(getSupportFragmentManager(), "Mario popup"); if (isDesfire == false) { if (intent.hasExtra(NfcAdapter.EXTRA_TAG)) { Toast.makeText(this, "NfcIntent", Toast.LENGTH_SHORT).show(); Log.i(nfcDebugTag, "Tag detectat"); Parcelable[] parcelables = intent.getParcelableArrayExtra(nfcAdapter.EXTRA_NDEF_MESSAGES); if (parcelables != null && parcelables.length > 0) { readTextFromTag((NdefMessage) parcelables[0]); } else { Toast.makeText(this, "No NDEF Message Found", Toast.LENGTH_SHORT).show(); } } else { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); String mesaj = "ce mai faci"; NdefMessage ndefMessage = createNdefMessage(mesaj); writeNdefMessage(tag, ndefMessage); } } if (isCardEmpty) { FragmentEmptyState Fragment = new FragmentEmptyState(); ChangeFragment(Fragment); // ChangeFragment(chooseOptions); // FragmentPinDialog fragment = new FragmentPinDialog(); // fragment.show(getSupportFragmentManager(), "Mario popup"); } else { Log.i(nfcDebugTag, "A ajuns pe else pana la fragment"); int lengthStack = getSupportFragmentManager().getFragments().size(); Fragment lastFragment = getSupportFragmentManager().getFragments().get(lengthStack - 1); boolean isDialogFragment = FragmentPinDialog.class.isInstance(lastFragment); if (!isDialogFragment) { FragmentPinDialog fragment = new FragmentPinDialog(); fragment.show(getSupportFragmentManager(), "Mario popup"); } } } catch (CloneDetectedException e) { Toast.makeText(this, "Error_with_warning", Toast.LENGTH_SHORT).show(); } catch (Exception e) { Log.i(nfcDebugTag, "Exceptia este" + e.getMessage()); } finally { isDesfire = false; } Log.i(nfcDebugTag, "Nfc intent a ajuns la sfarsit"); }