List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:com.soomla.example.ExampleSocialActivity.java
private void chooseImageFile() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, SELECT_PHOTO_ACTION); }
From source file:com.jtechme.apphub.FDroidApp.java
public void sendViaBluetooth(Activity activity, int resultCode, String packageName) { if (resultCode == Activity.RESULT_CANCELED) return;//from w w w.java 2 s . c o m String bluetoothPackageName = null; String className = null; boolean found = false; Intent sendBt = null; try { PackageManager pm = getPackageManager(); ApplicationInfo appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); sendBt = new Intent(Intent.ACTION_SEND); // The APK type is blocked by stock Android, so use zip // sendBt.setType("application/vnd.android.package-archive"); sendBt.setType("application/zip"); sendBt.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + appInfo.publicSourceDir)); // not all devices have the same Bluetooth Activities, so // let's find it for (ResolveInfo info : pm.queryIntentActivities(sendBt, 0)) { bluetoothPackageName = info.activityInfo.packageName; if ("com.android.bluetooth".equals(bluetoothPackageName) || "com.mediatek.bluetooth".equals(bluetoothPackageName)) { className = info.activityInfo.name; found = true; break; } } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Could not get application info to send via bluetooth", e); found = false; } if (sendBt != null) { if (found) { sendBt.setClassName(bluetoothPackageName, className); activity.startActivity(sendBt); } else { Toast.makeText(this, R.string.bluetooth_activity_not_found, Toast.LENGTH_SHORT).show(); activity.startActivity(Intent.createChooser(sendBt, getString(R.string.choose_bt_send))); } } }
From source file:com.polyvi.xface.extension.contact.XContactsExt.java
/** * ?//from w ww.j a v a 2 s . c o m * @param callbackCtx */ private void startContactActivity() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(ContactsContract.Contacts.CONTENT_TYPE); mExtensionContext.getSystemContext().startActivityForResult(this, intent, PICK_CONTACT); }
From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java
private void sendSMS(String msg) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setType("vnd.android-dir/mms-sms"); intent.putExtra("sms_body", msg); startActivity(intent);// ww w . j a v a 2s . c om }
From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java
private void sentGenericText(String subject, String msg) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, msg); startActivity(intent);/*ww w .j a va 2 s .c o m*/ }
From source file:com.google.android.apps.paco.FeedbackActivity.java
private void sendEmail(String body, String subject, String userEmail) { userEmail = findAccount(userEmail);//from w w w . java 2 s. co m Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); String aEmailList[] = { userEmail }; emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body); emailIntent.setType("plain/text"); startActivity(emailIntent); }
From source file:com.layer.atlas.messenger.AtlasMessagesScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.uiHandler = new Handler(); this.app = (MessengerApp) getApplication(); setContentView(R.layout.atlas_screen_messages); boolean convIsNew = getIntent().getBooleanExtra(EXTRA_CONVERSATION_IS_NEW, false); String convUri = getIntent().getStringExtra(EXTRA_CONVERSATION_URI); if (convUri != null) { Uri uri = Uri.parse(convUri);//from ww w .j a v a 2 s . c o m conv = app.getLayerClient().getConversation(uri); ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(convUri.hashCode()); // Clear notifications for this Conversation } participantsPicker = (AtlasParticipantPicker) findViewById(R.id.atlas_screen_messages_participants_picker); participantsPicker.init(new String[] { app.getLayerClient().getAuthenticatedUserId() }, app.getParticipantProvider()); if (convIsNew) { participantsPicker.setVisibility(View.VISIBLE); } messageComposer = (AtlasMessageComposer) findViewById(R.id.atlas_screen_messages_message_composer); messageComposer.init(app.getLayerClient(), conv); messageComposer.setListener(new AtlasMessageComposer.Listener() { public boolean beforeSend(Message message) { boolean conversationReady = ensureConversationReady(); if (!conversationReady) return false; // push preparePushMetadata(message); return true; } }); messageComposer.registerMenuItem("Photo", new OnClickListener() { public void onClick(View v) { if (!ensureConversationReady()) return; Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); String fileName = "cameraOutput" + System.currentTimeMillis() + ".jpg"; photoFile = new File(getExternalFilesDir(android.os.Environment.DIRECTORY_PICTURES), fileName); final Uri outputUri = Uri.fromFile(photoFile); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri); if (debug) Log.w(TAG, "onClick() requesting photo to file: " + fileName + ", uri: " + outputUri); startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA); } }); messageComposer.registerMenuItem("Image", new OnClickListener() { public void onClick(View v) { if (!ensureConversationReady()) return; // in onCreate or any event where your want the user to select a file Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_CODE_GALLERY); } }); messageComposer.registerMenuItem("Location", new OnClickListener() { public void onClick(View v) { if (!ensureConversationReady()) return; if (lastKnownLocation == null) { Toast.makeText(v.getContext(), "Inserting Location: Location is unknown yet", Toast.LENGTH_SHORT).show(); return; } String locationString = "{\"lat\":" + lastKnownLocation.getLatitude() + ", \"lon\":" + lastKnownLocation.getLongitude() + "}"; MessagePart part = app.getLayerClient().newMessagePart(Atlas.MIME_TYPE_ATLAS_LOCATION, locationString.getBytes()); Message message = app.getLayerClient().newMessage(Arrays.asList(part)); preparePushMetadata(message); conv.send(message); if (debug) Log.w(TAG, "onSendLocation() loc: " + locationString); } }); messagesList = (AtlasMessagesList) findViewById(R.id.atlas_screen_messages_messages_list); messagesList.init(app.getLayerClient(), app.getParticipantProvider()); if (USE_QUERY) { Query<Message> query = Query.builder(Message.class) .predicate(new Predicate(Message.Property.CONVERSATION, Predicate.Operator.EQUAL_TO, conv)) .sortDescriptor(new SortDescriptor(Message.Property.POSITION, SortDescriptor.Order.ASCENDING)) .build(); messagesList.setQuery(query); } else { messagesList.setConversation(conv); } messagesList.setItemClickListener(new ItemClickListener() { public void onItemClick(Cell cell) { if (Atlas.MIME_TYPE_ATLAS_LOCATION.equals(cell.messagePart.getMimeType())) { String jsonLonLat = new String(cell.messagePart.getData()); JSONObject json; try { json = new JSONObject(jsonLonLat); double lon = json.getDouble("lon"); double lat = json.getDouble("lat"); Intent openMapIntent = new Intent(Intent.ACTION_VIEW); String uriString = String.format(Locale.ENGLISH, "geo:%f,%f?z=%d&q=%f,%f", lat, lon, 18, lat, lon); final Uri geoUri = Uri.parse(uriString); openMapIntent.setData(geoUri); if (openMapIntent.resolveActivity(getPackageManager()) != null) { startActivity(openMapIntent); if (debug) Log.w(TAG, "onItemClick() starting Map: " + uriString); } else { if (debug) Log.w(TAG, "onItemClick() No Activity to start Map: " + geoUri); } } catch (JSONException ignored) { } } else if (cell instanceof ImageCell) { Intent intent = new Intent(AtlasMessagesScreen.this.getApplicationContext(), AtlasImageViewScreen.class); app.setParam(intent, cell); startActivity(intent); } } }); typingIndicator = (AtlasTypingIndicator) findViewById(R.id.atlas_screen_messages_typing_indicator); typingIndicator.init(conv, new AtlasTypingIndicator.DefaultTypingIndicatorCallback(app.getParticipantProvider())); // location manager for inserting locations: this.locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); prepareActionBar(); }
From source file:com.openerp.base.ir.Attachment.java
public void requestAttachment(Types type) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); switch (type) { case IMAGE_OR_CAPTURE_IMAGE: // createDialog(type); // break; case IMAGE://from ww w. j a va2 s .c o m intent.setType("image/*"); requestIntent(intent, REQUEST_IMAGE); break; case CAPTURE_IMAGE: intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); requestIntent(intent, REQUEST_CAMERA); break; case AUDIO: intent.setType("audio/*"); requestIntent(intent, REQUEST_AUDIO); break; case FILE: intent.setType("application/file"); requestIntent(intent, REQUEST_FILE); break; default: break; } }
From source file:com.example.android.naradaonline.DatagramFragment.java
protected final void sendEmail(DatagramRequest data) { if (data.type != DatagramRequestType.SEND_EMAIL) { Log.w(TAG, "This datagram is actually of type " + data.type.name()); }//from w ww . j a v a 2 s . c o m Log.i("Send email", ""); String[] TO = { data.mEmailTo }; Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setData(Uri.parse("mailto:")); emailIntent.setType("text/plain"); emailIntent.putExtra(Intent.EXTRA_EMAIL, TO); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Your Datagram"); emailIntent.putExtra(Intent.EXTRA_TEXT, data.mEmailBody); try { startActivity(Intent.createChooser(emailIntent, "Send mail...")); Log.i("Finished sending email...", ""); } catch (android.content.ActivityNotFoundException ex) { // Toast.makeText(MainActivity.this, // "There is no email client installed.", Toast.LENGTH_SHORT).show(); } }
From source file:it.mb.whatshare.MainActivity.java
private void onTellFriendsSelected() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/html"); intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.email_subject)); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(getResources().getString(R.string.email_body))); startActivity(Intent.createChooser(intent, getResources().getString(R.string.email_intent_msg))); }