List of usage examples for android.content Intent hasExtra
public boolean hasExtra(String name)
From source file:com.hybris.mobile.activity.NFCWriteActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.nfc_write);/*from w w w. j a v a 2 s. c o m*/ // acquire tag sent to this activity using intent extra Intent i = getIntent(); if (!i.hasExtra(NDEF_MESSAGE)) { Toast.makeText(this, R.string.error_nfc_no_ndef_message_sent, Toast.LENGTH_LONG).show(); finish(); } }
From source file:com.scooter1556.sms.android.activity.BrowseActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.d(TAG, "onCreate()"); setContentView(R.layout.activity_base); initialiseToolbar();//from ww w . j a v a 2 s . c o m setToolbarTitle(null); if (savedInstanceState == null) { Intent intent = getIntent(); if (intent == null || !intent.hasExtra(MediaUtils.EXTRA_MEDIA_ID)) { Log.e(TAG, "Browse activity started with no media id in the intent"); finish(); return; } // Set toolbar title setToolbarTitle(intent.getStringExtra(MediaUtils.EXTRA_MEDIA_TITLE)); // Set parent media item parentId = intent.getStringExtra(MediaUtils.EXTRA_MEDIA_ID); // Initialise fragment SimpleMediaFragment fragment = SimpleMediaFragment.newInstance(parentId); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.container, fragment, TAG_FRAGMENT); transaction.commit(); } }
From source file:com.karthikb351.vitinfo2.activity.DetailsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); List<Course> courseList = ((MainApplication) getApplication()).getDataHolderInstanceInitialized() .getCourses();/*from www. ja v a 2s . c o m*/ Intent intent = getIntent(); if (intent.hasExtra(Constants.INTENT_EXTRA_CLASS_NUMBER)) { setContentView(R.layout.activity_details); initToolbar(); loadProgress = (ProgressBar) findViewById(R.id.progress_bar_details); new LoadCourseTask(courseList).execute(intent.getIntExtra(Constants.INTENT_EXTRA_CLASS_NUMBER, -1)); } else { setContentView(R.layout.app_message_not_available); TextView errorMessage = (TextView) findViewById(R.id.message); errorMessage.setText(getString(R.string.not_available)); } }
From source file:com.renard.ocr.help.OCRLanguageInstallService.java
@Override protected void onHandleIntent(Intent intent) { if (!intent.hasExtra(DownloadManager.EXTRA_DOWNLOAD_ID)) { return;/* w ww . j a v a2s . co m*/ } final long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); if (downloadId != 0) { DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); ParcelFileDescriptor file; try { file = dm.openDownloadedFile(downloadId); FileInputStream fin = new FileInputStream(file.getFileDescriptor()); BufferedInputStream in = new BufferedInputStream(fin); FileOutputStream out = openFileOutput("tess-lang.tmp", Context.MODE_PRIVATE); GzipCompressorInputStream gzIn = new GzipCompressorInputStream(in); final byte[] buffer = new byte[2048 * 2]; int n = 0; while (-1 != (n = gzIn.read(buffer))) { out.write(buffer, 0, n); } out.close(); gzIn.close(); FileInputStream fileIn = openFileInput("tess-lang.tmp"); TarArchiveInputStream tarIn = new TarArchiveInputStream(fileIn); TarArchiveEntry entry = tarIn.getNextTarEntry(); while (entry != null && !(entry.getName().endsWith(".traineddata") && !entry.getName().endsWith("_old.traineddata"))) { entry = tarIn.getNextTarEntry(); } if (entry != null) { File tessDir = Util.getTrainingDataDir(this); final String langName = entry.getName().substring("tesseract-ocr/tessdata/".length()); File trainedData = new File(tessDir, langName); FileOutputStream fout = new FileOutputStream(trainedData); int len; while ((len = tarIn.read(buffer)) != -1) { fout.write(buffer, 0, len); } fout.close(); String lang = langName.substring(0, langName.length() - ".traineddata".length()); notifyReceivers(lang); } tarIn.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { String tessDir = Util.getTessDir(this); File targetFile = new File(tessDir, OCRLanguageActivity.DOWNLOADED_TRAINING_DATA); if (targetFile.exists()) { targetFile.delete(); } } } }
From source file:ch.ethz.twimight.activities.SearchableActivity.java
private void processIntent(Intent intent) { if (intent.hasExtra(SearchManager.QUERY)) { //if (!intent.getStringExtra(SearchManager.QUERY).equals(query)) query = intent.getStringExtra(SearchManager.QUERY); setTitle(getString(R.string.results_for) + query); SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this, TwimightSuggestionProvider.AUTHORITY, TwimightSuggestionProvider.MODE); suggestions.saveRecentQuery(query, null); }/* w w w .j a va 2 s. c o m*/ }
From source file:at.ac.uniklu.mobile.sportal.DashboardLogoutProgressDialogFragment.java
@Override public void onStart() { super.onStart(); if (mGCMCommunicator == null) { mGCMCommunicator = new GCMStatusBroadcastCommunicator() { @Override//from ww w . j a v a2 s .c o m public void onReceive(Context context, Intent intent) { if (intent.hasExtra(GCMStatusBroadcastCommunicator.EXTRA_GCM_UP)) { runLogoutTask(); } } }; /* Unregister from GCM. * If there's no GCM registration, immediately start the logout task... otherwise * wait for GCM to finish the unregistering process and then start the task (see above). */ if (!GCMUtils.unregisterIfRegistered(getActivity().getApplicationContext())) { runLogoutTask(); } } }
From source file:com.ibm.cloud.appid.android.internal.authorizationmanager.ChromeTabActivity.java
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (!intent.hasExtra(INTENT_ALREADY_USED)) { // First time onResume called we add INTENT_ALREADY_USED=true // to indicate that this intent was already active for the next time, // after the chrome tab closes by user. intent.putExtra(INTENT_ALREADY_USED, true); } else {/* w ww . j a v a 2s. com*/ // User cancelled authentication finish(); authorizationListener.onAuthorizationCanceled(); } }
From source file:com.stylovid.fastbattery.BatteryInfoActivity.java
private void routeIntent(Intent intent) { if (intent.hasExtra(BatteryInfoService.EXTRA_EDIT_ALARMS)) viewPager.setCurrentItem(2);/*from www . j av a 2s .c o m*/ else if (intent.hasExtra(BatteryInfoService.EXTRA_CURRENT_INFO)) viewPager.setCurrentItem(1); }
From source file:amhamogus.com.daysoff.EventsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_event); // Using butterknife for data binding ButterKnife.bind(this); Intent intent = getIntent(); if (intent.hasExtra(ARG_CURRENT_DATE)) { // Get user selected date from the intent selectedDate = intent.getExtras().getLong(ARG_CURRENT_DATE); dateSet = true;//from w w w . j a v a 2 s .c o m } else { // Date hasn't been passed through the intent. // Attempt to retrieve it from shared preferences. selectedDate = getSharedPreferences(PREF_FILE, Context.MODE_PRIVATE).getLong(PREF_SELECTED_DATE, 0); dateSet = true; } setSupportActionBar(toolbar); if (dateSet) { // Set user selected date as the Toolbar title to provide // additional context for the user. if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(new Date(selectedDate).toString().substring(0, 10)); } if (fragment == null) { fragment = EventDetailFragment.newInstance(selectedDate); } FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.add(R.id.event_frame, fragment).commit(); } else { AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this); alertBuilder.setTitle(R.string.events_activity_no_date_set) .setMessage(R.string.events_activity_no_date_set_message) .setPositiveButton(R.string.calendar_positive_button, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // Close the dialoge. } }); } }
From source file:com.pushwoosh.test.plugin.pushnotifications.PushNotifications.java
private void checkMessage(Intent intent) { if (null != intent) { if (intent.hasExtra(PushManager.PUSH_RECEIVE_EVENT)) { doOnMessageReceive(intent.getExtras().getString(PushManager.PUSH_RECEIVE_EVENT)); } else if (intent.hasExtra(PushManager.REGISTER_EVENT)) { doOnRegistered(intent.getExtras().getString(PushManager.REGISTER_EVENT)); } else if (intent.hasExtra(PushManager.UNREGISTER_EVENT)) { doOnUnregisteredError(intent.getExtras().getString(PushManager.UNREGISTER_EVENT)); } else if (intent.hasExtra(PushManager.REGISTER_ERROR_EVENT)) { doOnRegisteredError(intent.getExtras().getString(PushManager.REGISTER_ERROR_EVENT)); } else if (intent.hasExtra(PushManager.UNREGISTER_ERROR_EVENT)) { doOnUnregistered(intent.getExtras().getString(PushManager.UNREGISTER_ERROR_EVENT)); }//from w w w .j av a 2 s. c o m } }