Android Clipboard missing in Chooser - java

When I want to share basic plaintext in my app, the option to copy it in my clipboard does not show up in the chooserlist. Is there something wrong with my code? Or has my device a wrong setup?
String code = getXMLCode();
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, code);
startActivity(Intent.createChooser(sharingIntent, getString(R.string.shareXMLCode)));
public String getXMLCode(){...}

Android does not have a "copy to clipboard" option as part of ACTION_SEND. Certain apps, like Google Drive, might offer such a feature.
cketti recently wrote a blog post about how you can add your own "copy to clipboard" option to your own ACTION_SEND requests. In a nutshell, you use EXTRA_INITIAL_INTENTS to add another option to the chooser, one that points to your own activity that will offer "copy to clipboard".

Related

Android open external IMDB application from my app

I have a button in my application which opens the imdb application in the phone with a imdb id I received from https://developers.themoviedb.org/3/getting-started/introduction
But I couldnt find anyway(using intents) to make my app recognize the imdb app and open it and if imdb app do not exist then I want to open the web site. How can I accomplish this?
I think I may be able to point you in the right direction. Just to be sure, you seem to be using TMDB but wish to open in the IMDB app?
The code below is from the Android documentation.
It will start your intent if the package manager can find an app with the appropriate intent filter installed on your device. If multiple apps are able to open this intent then an app chooser should pop up, unless the user has previously set a default for this kind of URI.
Intent sendIntent = new Intent(Intent.ACTION_SEND);
// Always use string resources for UI text.
// This says something like "Share this photo with"
String title = getResources().getString(R.string.chooser_title);
// Create intent to show the chooser dialog
Intent chooser = Intent.createChooser(sendIntent, title);
// Verify the original intent will resolve to at least one activity
if (sendIntent.resolveActivity(getPackageManager()) != null) {
startActivity(chooser);
}
If you add an else onto that then you can use a view intent like this :
Intent internetIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(movieUrl));
//Watch out here , There is a URI and Uri class!!!!
if (internetIntent.resolveActivity(getPackageManager()) != null){
startActivity(internetIntent);
}
I also found this (rather old) post about calling an explicit imdb uri
Imdb description
startActivity(android.intent.action.VIEW, imdb:///title/<titleID>);
// take note of the Uri scheme "imdb"
I hope this helps. If you post some more detail , code, links , I might be able to work through this with you.
If my answer is way off base then please be kind and set me right. We are all learning every day!
Good Luck.

Android direct shared

I am trying to share a link from my app with direct share. The share dialog must be like the image below with the most used contacts from messaging apps, like WhatsApp contacts.
This is the Intent structure which I am using for share the link:
Intent shareIntent = ShareCompat.IntentBuilder
.from(getActivity())
.setType("text/plain")
.setText(sTitle+ "\n" + urlPost)
.getIntent();
if (shareIntent.resolveActivity(
getActivity().getPackageManager()) != null)
startActivity(shareIntent);
And this is what my app shows:
Any idea how to achieve that?
You should use .createChooserIntent() instead of .getIntent()
Like this code below, you can use Intent.createChooser
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file://" + filePath);
sharingIntent.setType("image/png");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
You should use .createChooserIntent() instead of .getIntent()
Docs: This uses the ACTION_CHOOSER intent, which shows
an activity chooser, allowing the user to pick what they want to before proceeding. This can be used as an alternative to the standard activity picker that is displayed by the system when you try to start an activity with multiple possible matches, with these differences in behavior:
You can specify the title that will appear in the activity chooser.
The user does not have the option to make one of the matching activities a preferred activity, and all possible activities will
always be shown even if one of them is currently marked as the
preferred activity.
This action should be used when the user will naturally expect to
select an activity in order to proceed. An example if when not to use
it is when the user clicks on a "mailto:" link. They would naturally
expect to go directly to their mail app, so startActivity() should be
called directly: it will either launch the current preferred app, or
put up a dialog allowing the user to pick an app to use and optionally
marking that as preferred.
In contrast, if the user is selecting a menu item to send a picture
they are viewing to someone else, there are many different things they
may want to do at this point: send it through e-mail, upload it to a
web service, etc. In this case the CHOOSER action should be used, to
always present to the user a list of the things they can do, with a
nice title given by the caller such as "Send this photo with:".

Share my app via specific apps only

I want to create a sharing button via some applications only.
right now I`m using this code:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "App Name");
intent.putExtra(Intent.EXTRA_TEXT, "Check out this cool app http://market.android.com/details?id=com.example.yourpackagename");
Intent chooser = Intent.createChooser(intent, "Tell a friend about App Name");
startActivity(chooser);
But it opens a huge window with all the apps installed at the device. I want to show only chosen options (Facebook, Whatsapp, Gmail).
Thank you.
Have a look at this answer, I would suggest going with it : https://stackoverflow.com/a/9755553/1542720
Some other workarounds/solutions :
http://hkdevtips.blogspot.in/2013/02/customize-your-actionchooser-intent.html
Custom filtering of intent chooser based on installed Android package name

send mms without user interaction in android

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.putExtra("address", "12134567899");
intent.putExtra("sms_body", "See attached picture");
intent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/DCIM/Camera/2011-09-09 12.47.29.jpg"));
intent.setType("image/png");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
i try code like this. if intent start mms compose ui was coming how can i overcome and send automatically
First of all. good luck.
Since MMS isn't supported by the android sdk, you have 2 options:
download the android mms aplication and try to understand what's going on there.
follow this link:
http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html
only thing I found working at the moment....
This feature was designed as a safety feature in Android, please do not try to bypass it. It's there for a reason.
If you absolutly must, have you tried running it on a rooted device? It allows greater access.
try this its worked with me .
use
Uri.fromFile
instead of
Uri.parse
File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/Camera/"+img_name);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("", "");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sendIntent.setType("image/png");
startActivity(sendIntent);

How to use other applications to send pictures?

How to you make it so if a user does something, it asks them how they want to do it and it brings them to that application? Like if you go "Share" a photo or video it pops up a list with all apps that can do that for you like facebook or text or email , ect.? I am asking how to have my app use other apps, not them use mine.
You do this by targeting the intent filter that the other apps use.
For example, if I want to share a picture, I can do this:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/test.jpg"));
startActivity(Intent.createChooser(share, "Share image"));
Then you will get a popup to choose the app to use for this action.

Categories