List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:com.glabs.homegenie.widgets.MediaServerDialogFragment.java
private void playMediaTo() { // _selectedMedia String apicall = _module.Domain + "/" + _module.Address + "/AvMedia.GetUri/" + _selectedMedia.Id + "/"; Control.callServiceApi(apicall, new Control.ServiceCallCallback() { @Override/* w w w .ja va 2s .c o m*/ public void serviceCallCompleted(String mediauri) { // send to currently selected media renderer if (_selectedMediaRender == null) // send to this device { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(mediauri)); if (mediauri.endsWith(".mp3") || mediauri.endsWith(".m4a") || mediauri.endsWith(".wav")) { i.setType("audio/*"); } else if (mediauri.endsWith(".jpeg") || mediauri.endsWith(".jpg") || mediauri.endsWith(".png") || mediauri.endsWith(".gif") || mediauri.endsWith(".tiff")) { // use default browser, internal image gallery won't work for external files //i.setType("image/*"); } else if (mediauri.endsWith(".m4v") || mediauri.endsWith(".3gp") || mediauri.endsWith(".wmv") || mediauri.endsWith(".mp4") || mediauri.endsWith(".mpeg") || mediauri.endsWith(".mpg") || mediauri.endsWith(".avi") || mediauri.endsWith(".ogg")) { i.setType("video/*"); } _view.getContext().startActivity(i); } else { String apicall; try { apicall = _selectedMediaRender.Domain + "/" + _selectedMediaRender.Address + "/AvMedia.SetUri/" + URLEncoder.encode(mediauri, "UTF-8") + "/"; Control.callServiceApi(apicall, new Control.ServiceCallCallback() { @Override public void serviceCallCompleted(String response) { // should play and popup current renderer controls dialog Control.callServiceApi(_selectedMediaRender.Domain + "/" + _selectedMediaRender.Address + "/AvMedia.Play/", null); } }); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } } }); }
From source file:com.todoroo.astrid.sync.SyncProviderPreferences.java
/** * * @param resource/* www.j av a2s . co m*/ * if null, updates all resources */ @Override public void updatePreferences(Preference preference, Object value) { final Resources r = getResources(); // interval if (r.getString(getUtilities().getSyncIntervalKey()).equals(preference.getKey())) { int index = AndroidUtilities.indexOf(r.getStringArray(R.array.sync_SPr_interval_values), (String) value); if (index <= 0) preference.setSummary(R.string.sync_SPr_interval_desc_disabled); else preference.setSummary(r.getString(R.string.sync_SPr_interval_desc, r.getStringArray(R.array.sync_SPr_interval_entries)[index])); } // status else if (r.getString(R.string.sync_SPr_status_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); String status; //String subtitle = ""; //$NON-NLS-1$ // ! logged in - display message, click -> sync if (!loggedIn) { status = r.getString(R.string.sync_status_loggedout); statusColor = Color.rgb(19, 132, 165); } // sync is occurring else if (getUtilities().isOngoing()) { status = r.getString(R.string.sync_status_ongoing); statusColor = Color.rgb(0, 0, 100); } // last sync had errors else if (getUtilities().getLastError() != null || getUtilities().getLastAttemptedSyncDate() != 0) { // last sync was failure if (getUtilities().getLastAttemptedSyncDate() != 0) { status = r.getString(R.string.sync_status_failed, DateUtilities.getDateStringWithTime( SyncProviderPreferences.this, new Date(getUtilities().getLastAttemptedSyncDate()))); statusColor = Color.rgb(100, 0, 0); if (getUtilities().getLastSyncDate() > 0) { // subtitle = r.getString(R.string.sync_status_failed_subtitle, // DateUtilities.getDateStringWithTime(SyncProviderPreferences.this, // new Date(getUtilities().getLastSyncDate()))); } } else { long lastSyncDate = getUtilities().getLastSyncDate(); String dateString = lastSyncDate > 0 ? DateUtilities.getDateStringWithTime(SyncProviderPreferences.this, new Date(lastSyncDate)) : ""; //$NON-NLS-1$ status = r.getString(R.string.sync_status_errors, dateString); statusColor = Color.rgb(100, 100, 0); } } else if (getUtilities().getLastSyncDate() > 0) { status = r.getString(R.string.sync_status_success, DateUtilities.getDateStringWithTime( SyncProviderPreferences.this, new Date(getUtilities().getLastSyncDate()))); statusColor = Color.rgb(0, 100, 0); } else { status = r.getString(R.string.sync_status_never); statusColor = Color.rgb(0, 0, 100); } preference.setTitle(R.string.sync_SPr_sync); preference.setSummary(r.getString(R.string.sync_SPr_status_subtitle, status)); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { startSync(); return true; } }); View view = findViewById(R.id.status); if (view != null) view.setBackgroundColor(statusColor); } else if (r.getString(R.string.sync_SPr_key_last_error).equals(preference.getKey())) { if (getUtilities().getLastError() != null) { // Display error final String service = getTitle().toString(); final String lastErrorFull = getUtilities().getLastError(); final String lastErrorDisplay = adjustErrorForDisplay(r, lastErrorFull, service); preference.setTitle(R.string.sync_SPr_last_error); preference.setSummary(R.string.sync_SPr_last_error_subtitle); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override @SuppressWarnings("nls") public boolean onPreferenceClick(Preference pref) { // Show last error new AlertDialog.Builder(SyncProviderPreferences.this).setTitle(R.string.sync_SPr_last_error) .setMessage(lastErrorDisplay) .setPositiveButton(R.string.sync_SPr_send_report, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text") .putExtra(Intent.EXTRA_EMAIL, new String[] { "android-bugs@astrid.com" }) .putExtra(Intent.EXTRA_SUBJECT, service + " Sync Error") .putExtra(Intent.EXTRA_TEXT, lastErrorFull); startActivity(Intent.createChooser(emailIntent, r.getString(R.string.sync_SPr_send_report))); } }).setNegativeButton(R.string.DLG_close, null).create().show(); return true; } }); } else { PreferenceCategory statusCategory = (PreferenceCategory) findPreference( r.getString(R.string.sync_SPr_group_status)); statusCategory.removePreference(findPreference(r.getString(R.string.sync_SPr_key_last_error))); } } // log out button else if (r.getString(R.string.sync_SPr_forget_key).equals(preference.getKey())) { boolean loggedIn = getUtilities().isLoggedIn(); preference.setOnPreferenceClickListener(new OnPreferenceClickListener() { public boolean onPreferenceClick(Preference p) { DialogUtilities.okCancelDialog(SyncProviderPreferences.this, r.getString(R.string.sync_forget_confirm), new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { logOut(); initializePreference(getPreferenceScreen()); } }, null); return true; } }); if (!loggedIn) { PreferenceCategory category = (PreferenceCategory) findPreference( r.getString(R.string.sync_SPr_key_options)); category.removePreference(preference); } } }
From source file:com.crowflying.buildwatch.ConfigurationActivity.java
@Override public boolean onPreferenceClick(Preference preference) { Log.d(LOG_TAG, String.format("Preference %s was clicked...", preference.getKey())); // Call the code for autosetup... if (PREFS_AUTOSETUP.equals(preference.getKey())) { Log.i(LOG_TAG, "Calling XZING."); tracker.trackEvent("configuration", "subscreen", "autosetup", 0L); IntentIntegrator integrator = new IntentIntegrator(this); integrator.setMessageByID(R.string.barcode_scanner_not_installed_message); integrator.initiateScan();/*from w w w . j a va 2s. co m*/ return true; } if (PREFS_FORGET_SETTINGS.equals(preference.getKey())) { Log.i(LOG_TAG, "Forgetting all settings"); tracker.trackEvent("configuration", "action", "settings_cleared", 0L); PreferenceManager.getDefaultSharedPreferences(this).edit().clear().commit(); return true; } if (PREFS_KEY_LAUNCH_WEBSITE.equals(preference.getKey())) { Log.i(LOG_TAG, "Launching website"); Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(getString(R.string.config_launch_website_url))); startActivity(i); return true; } if (PREFS_KEY_GCM_TOKEN.equals(preference.getKey())) { String token = getPreferenceManager().getSharedPreferences().getString(PREFS_KEY_GCM_TOKEN, ""); if (!TextUtils.isEmpty(token)) { Log.i(LOG_TAG, "Token clicked. Echoing it to the logfile for convencience: " + token); Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.share_gcm_token_subject)); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, token); startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_gcm_token_using))); } return true; } return false; }
From source file:org.jnegre.android.osmonthego.service.ExportService.java
/** * Handle export in the provided background thread *///from w w w . j a v a 2s . co m private void handleOsmExport(boolean includeAddress, boolean includeFixme) { //TODO handle empty survey //TODO handle bounds around +/-180 if (!isExternalStorageWritable()) { notifyUserOfError(); return; } int id = 0; double minLat = 200; double minLng = 200; double maxLat = -200; double maxLng = -200; StringBuilder builder = new StringBuilder(); if (includeAddress) { Uri uri = AddressTableMetaData.CONTENT_URI; Cursor cursor = getContentResolver().query(uri, new String[] { //projection AddressTableMetaData.LATITUDE, AddressTableMetaData.LONGITUDE, AddressTableMetaData.NUMBER, AddressTableMetaData.STREET }, null, //selection string null, //selection args array of strings null); //sort order if (cursor == null) { notifyUserOfError(); return; } try { int iLat = cursor.getColumnIndex(AddressTableMetaData.LATITUDE); int iLong = cursor.getColumnIndex(AddressTableMetaData.LONGITUDE); int iNumber = cursor.getColumnIndex(AddressTableMetaData.NUMBER); int iStreet = cursor.getColumnIndex(AddressTableMetaData.STREET); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { //Gather values double lat = cursor.getDouble(iLat); double lng = cursor.getDouble(iLong); String number = cursor.getString(iNumber); String street = cursor.getString(iStreet); minLat = Math.min(minLat, lat); maxLat = Math.max(maxLat, lat); minLng = Math.min(minLng, lng); maxLng = Math.max(maxLng, lng); builder.append("<node id=\"-").append(++id).append("\" lat=\"").append(lat).append("\" lon=\"") .append(lng).append("\" version=\"1\" action=\"modify\">\n"); addOsmTag(builder, "addr:housenumber", number); addOsmTag(builder, "addr:street", street); builder.append("</node>\n"); } } finally { cursor.close(); } } if (includeFixme) { Uri uri = FixmeTableMetaData.CONTENT_URI; Cursor cursor = getContentResolver().query(uri, new String[] { //projection FixmeTableMetaData.LATITUDE, FixmeTableMetaData.LONGITUDE, FixmeTableMetaData.COMMENT }, null, //selection string null, //selection args array of strings null); //sort order if (cursor == null) { notifyUserOfError(); return; } try { int iLat = cursor.getColumnIndex(FixmeTableMetaData.LATITUDE); int iLong = cursor.getColumnIndex(FixmeTableMetaData.LONGITUDE); int iComment = cursor.getColumnIndex(FixmeTableMetaData.COMMENT); for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { //Gather values double lat = cursor.getDouble(iLat); double lng = cursor.getDouble(iLong); String comment = cursor.getString(iComment); minLat = Math.min(minLat, lat); maxLat = Math.max(maxLat, lat); minLng = Math.min(minLng, lng); maxLng = Math.max(maxLng, lng); builder.append("<node id=\"-").append(++id).append("\" lat=\"").append(lat).append("\" lon=\"") .append(lng).append("\" version=\"1\" action=\"modify\">\n"); addOsmTag(builder, "fixme", comment); builder.append("</node>\n"); } } finally { cursor.close(); } } try { File destinationFile = getDestinationFile(); destinationFile.getParentFile().mkdirs(); PrintWriter writer = new PrintWriter(destinationFile, "UTF-8"); writer.println("<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>"); writer.println("<osm version=\"0.6\" generator=\"OsmOnTheGo\">"); writer.print("<bounds minlat=\""); writer.print(minLat - MARGIN); writer.print("\" minlon=\""); writer.print(minLng - MARGIN); writer.print("\" maxlat=\""); writer.print(maxLat + MARGIN); writer.print("\" maxlon=\""); writer.print(maxLng + MARGIN); writer.println("\" />"); writer.println(builder); writer.print("</osm>"); writer.close(); if (writer.checkError()) { notifyUserOfError(); } else { //FIXME i18n the subject and content Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); emailIntent.setType(HTTP.OCTET_STREAM_TYPE); //emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"johndoe@exemple.com"}); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "OSM On The Go"); emailIntent.putExtra(Intent.EXTRA_TEXT, "Your last survey."); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(destinationFile)); startActivity(emailIntent); } } catch (IOException e) { Log.e(TAG, "Could not write to file", e); notifyUserOfError(); } }
From source file:com.example.android.wifidirect.DeviceDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mContentView = inflater.inflate(R.layout.device_detail, null); mContentView.findViewById(R.id.btn_connect).setOnClickListener(new View.OnClickListener() { @Override/*from w w w .j a va2s. c o m*/ public void onClick(View v) { WifiP2pConfig config = new WifiP2pConfig(); config.deviceAddress = device.deviceAddress; config.wps.setup = WpsInfo.PBC; if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } progressDialog = ProgressDialog.show(getActivity(), "Press back to cancel", "Connecting to :" + device.deviceAddress, true, true // new DialogInterface.OnCancelListener() { // // @Override // public void onCancel(DialogInterface dialog) { // ((DeviceActionListener) getActivity()).cancelDisconnect(); // } // } ); ((DeviceActionListener) getActivity()).connect(config); } }); mContentView.findViewById(R.id.btn_send_data); mContentView.findViewById(R.id.btn_disconnect).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ((DeviceActionListener) getActivity()).disconnect(); } }); mContentView.findViewById(R.id.btn_start_client).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Allow user to pick an image from Gallery or other // registered apps Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, CHOOSE_FILE_RESULT_CODE); } }); return mContentView; }
From source file:org.ueu.uninet.it.IragarkiaBidali.java
/** * Prestatu iragarki berria bidaltzeko formularioa *//*from www.j a v a 2s.c o m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.iragarkia_bidali); this.ekintza = this; this.izena = (EditText) findViewById(R.id.editTextIzena); this.izenburua = (EditText) findViewById(R.id.editTextIzenburua); this.eposta = (EditText) findViewById(R.id.editTextEposta); this.telefonoa = (EditText) findViewById(R.id.editTextTelefonoa); this.mezua = (EditText) findViewById(R.id.editTextDeskribapena); this.ohar_legala = (CheckBox) findViewById(R.id.checkBoxlegalAdviceBidali); this.errobota = (EditText) findViewById(R.id.editTextErrobota); this.atala = (Spinner) findViewById(R.id.spinnerAtala); imgView = (ImageView) findViewById(R.id.ImageView); upload = (Button) findViewById(R.id.Upload); bidali = (Button) findViewById(R.id.iragarkiaBidali); // Iragarkiak irudirik badu galeriatik kargatu upload.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Toast.makeText(getApplicationContext(), "Aukeratu irudi bat.", Toast.LENGTH_SHORT).show(); try { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Irudia aukeratu"), PICK_IMAGE); } catch (Exception e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } }); // Formularioa bidali bidali.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (balidatu()) { dialog = ProgressDialog.show(IragarkiaBidali.this, "Fitxategia igotzen eta mezua bidaltzen", "Itxaron mesedez...", true); //Formularioa eta irudia bidali new ImageUploadTask().execute(); } } }); ArrayAdapter<String> iragarki_motak = new ArrayAdapter<String>(this, R.layout.spinner_view, getResources().getStringArray(R.array.iragarki_kategoriak)); iragarki_motak.setDropDownViewResource(R.layout.spinner_view_dropdown); this.atala.setAdapter(iragarki_motak); // Sareko monitora prestatu NetworkConnectivity.sharedNetworkConnectivity().configure(this); NetworkConnectivity.sharedNetworkConnectivity().addNetworkMonitorListener(this); NetworkConnectivity.sharedNetworkConnectivity().startNetworkMonitor(); }
From source file:com.code.android.vibevault.FeaturedShowsScreen.java
/** Handle user's long-click selection. * *///w w w . j a va 2 s . co m @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (menuInfo != null) { ArchiveShowObj selShow = (ArchiveShowObj) featuredShowsList.getAdapter().getItem(menuInfo.position); switch (item.getItemId()) { case VibeVault.EMAIL_LINK: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Great show on archive.org: " + selShow.getArtistAndTitle()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey,\n\nYou should listen to " + selShow.getArtistAndTitle() + ". You can find it here: " + selShow.getShowURL() + "\n\nSent using VibeVault for Android."); startActivity(Intent.createChooser(emailIntent, "Send mail...")); return true; case (VibeVault.ADD_TO_FAVORITE_LIST): VibeVault.db.insertFavoriteShow(selShow); return true; default: break; } return false; } return true; }
From source file:com.intel.xdk.contacts.Contacts.java
public void chooseContact() { try {//from w w w .ja v a2 s . c om if (busy == true) { String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.busy',true,true);e.success=false;e.message='busy';document.dispatchEvent(e);"; injectJS(js); return; } busy = true; Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); cordova.setActivityResultCallback(this); activity.startActivityForResult(intent, CONTACT_CHOOSER_RESULT); //activity.setLaunchedChildActivity(true); } catch (Exception e) { e.printStackTrace(); } }
From source file:net.networksaremadeofstring.rhybudd.ViewZenossEvent.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: { finish();//from w w w . jav a 2s . c o m return true; } case R.id.AddLog: { addMessageDialog = new Dialog(ViewZenossEvent.this); addMessageDialog.setContentView(R.layout.add_message); addMessageDialog.setTitle("Add Message to Event Log"); ((Button) addMessageDialog.findViewById(R.id.SaveButton)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AddLogMessage(((EditText) addMessageDialog.findViewById(R.id.LogMessage)).getText().toString()); addMessageDialog.dismiss(); } }); addMessageDialog.show(); return true; } case R.id.escalate: { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("text/plain"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // Add data to the intent, the receiving app will decide what to do with it. intent.putExtra(Intent.EXTRA_SUBJECT, "Escalation of Zenoss Event on " + getIntent().getStringExtra("Device")); String EventDetails = getIntent().getStringExtra("Summary") + "\r\r\n" + getIntent().getStringExtra("LastTime") + "\r\r\n" + "Count: " + getIntent().getIntExtra("Count", 0); intent.putExtra(Intent.EXTRA_TEXT, EventDetails); startActivity(Intent.createChooser(intent, "How would you like to escalate this event?")); } default: { return false; } } }