List of usage examples for android.content Intent getType
public @Nullable String getType()
From source file:org.exoplatform.shareextension.ShareActivity.java
private boolean isIntentCorrect() { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); mMultiFlag = Intent.ACTION_SEND_MULTIPLE.equals(action); return ((Intent.ACTION_SEND.equals(action) || mMultiFlag) && type != null); }
From source file:org.exoplatform.shareextension.ShareActivity.java
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); setContentView(R.layout.share_extension_activity); loadingIndicator = (ProgressBar) findViewById(R.id.share_progress_indicator); mainButton = (Button) findViewById(R.id.share_button); mainButton.setTag(R.attr.share_button_type_post); online = false;//from w w w . j a va2 s. c o m postInfo = new SocialPostInfo(); if (isIntentCorrect()) { Intent intent = getIntent(); String type = intent.getType(); if ("text/plain".equals(type)) { // The share does not contain an attachment // TODO extract the link info - MOB-1866 postInfo.postMessage = intent.getStringExtra(Intent.EXTRA_TEXT); } else { // The share contains an attachment if (mMultiFlag) { mAttachmentUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); } else { Uri contentUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM); if (contentUri != null) { mAttachmentUris = new ArrayList<Uri>(); mAttachmentUris.add(contentUri); } if (Log.LOGD) { Log.d(LOG_TAG, "Number of files to share: ", mAttachmentUris.size()); } } prepareAttachmentsAsync(); } init(); // Create and display the composer, aka ComposeFragment ComposeFragment composer = ComposeFragment.getFragment(); openFragment(composer, ComposeFragment.COMPOSE_FRAGMENT, Anim.NO_ANIM); } else { // We're not supposed to reach this activity by anything else than an // ACTION_SEND intent finish(); } }
From source file:org.totschnig.sendwithftp.FtpTransfer.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent(); target = intent.getData();/*from w w w .j ava2s. c o m*/ task = (FtpAsyncTask) getLastNonConfigurationInstance(); if (task != null) { showProgressDialog(); task.attach(this); if (task.getStatus() == AsyncTask.Status.FINISHED) { markAsDone(); } } else { String type = intent.getType(); is = null; fileName = null; if (type != null) { Log.i("FtpTransfer", type); if ("text/plain".equals(type)) { handleSendText(intent); // Handle text being sent } else if ("text/x-vcard".equals(type)) { handleSendVcard(intent); // Handle vcard being sent } else if (type.startsWith("image/")) { handleSendImage(intent); // Handle single image being sent } } if (is == null) { handleFallBack(intent); } if (is != null) { showProgressDialog(); Log.i("FtpTransfer", "fileType: " + fileType); task = new FtpAsyncTask(this, is, target, fileName, fileType); task.execute(); } else { Toast.makeText(getBaseContext(), "Cannot handle shared data", Toast.LENGTH_LONG).show(); finish(); } } }
From source file:com.example.linhdq.test.documents.viewing.grid.DocumentGridActivity.java
private void checkForImageIntent(Intent intent) { String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type != null) { Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) { loadBitmapFromContentUri(imageUri, ImageSource.INTENT); } else {//from w w w.ja va2s. c o m showFileError(PixLoadStatus.IMAGE_COULD_NOT_BE_READ, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }); } } }
From source file:org.tigase.mobile.chat.ChatHistoryFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == TigaseMobileMessengerActivity.SELECT_FOR_SHARE && resultCode == Activity.RESULT_OK) { Uri selected = data.getData();/*from w w w. j a v a 2 s. c o m*/ String mimetype = data.getType(); RosterItem ri = chat.getSessionObject().getRoster().get(chat.getJid().getBareJid()); JID jid = chat.getJid(); final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext()).getMultiJaxmpp() .get(ri.getSessionObject()); if (jid.getResource() == null) { jid = FileTransferUtility.getBestJidForFeatures(jaxmpp, jid.getBareJid(), FileTransferUtility.FEATURES); } if (jid != null) { FileTransferUtility.startFileTransfer(getActivity(), jaxmpp, chat.getJid(), selected, mimetype); } } }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.Main.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); {/* w ww . ja v a2 s. c o m*/ // Use intent in case the app was started by another app to send messages/images Intent intent = getIntent(); if (intent != null) { Uri data = intent.getData(); if (intent.getType() != null) { // Figure out what to do based on the intent type if (intent.getType().contains("image/")) { // Handle intents with image data ... // should probably set here a window only to select contact destination // Create intent to deliver some kind of result data //Intent result = new Intent("net.ddp2p.RESULT_ACTION", Uri.parse("content://result_uri")); // setResult(Activity.RESULT_OK, result); setResult(Activity.RESULT_CANCELED); finish(); } else if (intent.getType().equals("text/plain")) { // Handle intents with text ... // should probably set here a window only to select contact destination // Create intent to deliver some kind of result data //Intent result = new Intent("net.ddp2p.RESULT_ACTION", Uri.parse("content://result_uri")); // setResult(Activity.RESULT_OK, result); setResult(Activity.RESULT_CANCELED); finish(); } } } } setContentView(R.layout.main); //initial action bar actionBar = this.getActionBar(); //set tab navigation mode actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //initial view pager mViewPager = (ViewPager) this.findViewById(R.id.pager); actionBar.setDisplayHomeAsUpEnabled(false); //add adapter mAdapter = new TabFragmentPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mAdapter); mViewPager.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageSelected(int position) { // if (position > 1) position = 1; actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); //add tabs actionBar.addTab(actionBar.newTab().setText(Util.__("Connections")).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(Util.__("Organizations")).setTabListener(this)); if (PAGES_NB > 2) { actionBar.addTab(actionBar.newTab().setText("Acts").setTabListener(this)); } new net.ddp2p.common.util.DDP2P_ServiceThread("loading icons", false, this) { @Override public void _run() { Main m = (Main) ctx; Bitmap bmp = PhotoUtil.decodeSampledBitmapFromResource(getResources(), R.drawable.organization_default_img, 55, 55); icon_org = PhotoUtil.BitmapToByteArray(bmp, 100); } }.start(); }
From source file:org.catnut.ui.ComposeTweetActivity.java
private void handleOuterShare() { Intent intent = getIntent(); String action = intent.getAction(); String mimeType = intent.getType(); if (!TextUtils.isEmpty(action)) { if (!TextUtils.isEmpty(mimeType)) { if (mimeType.equals(getString(R.string.mime_text_plain))) { mText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); setResult(RESULT_OK); // no result return back } else if (mimeType.startsWith("image/")) { mText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); if (mUris == null) { initGallery();/* w ww. j ava 2s. c o m*/ // ??binary data??uri // ?? mUris.add((Uri) intent.getExtras().get(Intent.EXTRA_STREAM)); mAdapter.notifyDataSetChanged(); setResult(RESULT_OK); } } else { setResult(RESULT_CANCELED); } } else { setResult(RESULT_CANCELED); } } }
From source file:com.android.gallery3d.app.Gallery.java
private void initializeByIntent() { Intent intent = getIntent(); String action = intent.getAction(); if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) { startGetContent(intent);//from w w w . j a v a2 s . c om } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) { // We do NOT really support the PICK intent. Handle it as // the GET_CONTENT. However, we need to translate the type // in the intent here. Log.w(TAG, "action PICK is not supported"); String type = Utils.ensureNotNull(intent.getType()); if (type.startsWith("vnd.android.cursor.dir/")) { if (type.endsWith("/image")) intent.setType("image/*"); if (type.endsWith("/video")) intent.setType("video/*"); } startGetContent(intent); } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action) || ACTION_REVIEW.equalsIgnoreCase(action)) { startViewAction(intent); } else { startDefaultPage(); } }
From source file:com.studyjams.mdvideo.PlayerModule.PlayerActivity.java
private void onShown() { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if (Intent.ACTION_SEND.equals(action) && type.equals("video/*")) { contentUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); contentType = Util.TYPE_SS; contentId = ""; provider = "0"; } else {/*from www .j a v a 2 s .c o m*/ contentUri = intent.getData(); contentType = intent.getIntExtra(CONTENT_TYPE_EXTRA, inferContentType(contentUri, intent.getStringExtra(CONTENT_EXT_EXTRA))); contentId = intent.getStringExtra(CONTENT_ID_EXTRA); provider = intent.getStringExtra(PROVIDER_EXTRA); } configureSubtitleView(); if (player == null) { if (!maybeRequestPermission()) { preparePlayer(true); } } else { player.setBackgrounded(false); } }
From source file:com.raspi.chatapp.ui.chatting.ChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The namespace I am using in the UploadService is the app id UploadService.NAMESPACE = BuildConfig.APPLICATION_ID; // the layout contains just the toolbar and the FrameLayout which // contains every fragment setContentView(R.layout.activity_chat); // manage the backstack, therefore, I got a function that checks whether I // can go back and sets the back button in the actionbar accordingly getSupportFragmentManager().addOnBackStackChangedListener(this); shouldDisplayHomeUp();/*from www .ja v a 2 s . c o m*/ // in case this is the first time the app launches or in case the user // deleted all application data set my buddyId and pwd I use to log into // the XMPP server setUserPwd(); // if there is a calling intent and this contains a buddyId and chatName // do not open the chatFragmet instantly but only set the current // variables in order to be able to ask for a password if necessary, see // onResume. Intent callingIntent = getIntent(); Bundle extras = callingIntent.getExtras(); String type = callingIntent.getType(); if (Intent.ACTION_SEND.equals(callingIntent.getAction()) && type != null) { if (type.startsWith("image/")) { imageUri = callingIntent.getParcelableExtra(Intent.EXTRA_STREAM); } } if (extras != null && extras.containsKey(Constants.BUDDY_ID) && extras.containsKey(Constants.CHAT_NAME)) { currentBuddyId = extras.getString(Constants.BUDDY_ID); currentChatName = extras.getString(Constants.CHAT_NAME); } }